TorchLean API

NN.Runtime.Autograd.Model.Functional.Spectral

One-sided spectral convolution #

Both execution paths use the same weights, indexed by [frequency, input channel, output channel]. Only the stored nonnegative frequencies are learned. The normalized inverse supplies the conjugate negative frequencies and ignores imaginary DC and Nyquist coordinates.

Keeping the dense path explicit makes comparisons meaningful: changing SpectralPath changes the implementation, while preserving the parameters, activation, and real-valued spectral map. Floating-point results can differ; dense zero-coefficient products do not suppress NaN or infinity.

def Runtime.Autograd.Model.F.Fourier.padFrequencies {α : Type} [TorchLean.Storage α] [Context α] {m : Type → Type} [Monad m] [Ops m α] {modes frequencies width : ℕ} (h : modes ≤ frequencies) (x : Ref [modes, width]) :
m (Ref [frequencies, width])

Restore discarded frequencies as zeros before the inverse transform.

Instances For
    def Runtime.Autograd.Model.F.spectralConv {α : Type} [TorchLean.Storage α] [Context α] {m : Type → Type} [Monad m] [Ops m α] {grid width modes : ℕ} (_hgrid : 0 < grid) (_hwidth : 0 < width) (hmodes : modes ≤ grid / 2 + 1) (x : Ref [grid, width]) (realWeight imagWeight : Ref [modes, width, width]) (path : SpectralPath := SpectralPath.automatic) :
    m (Ref [grid, width])

    Apply learned channel maps to the first modes nonnegative Fourier bins.

    Inputs and outputs have shape [grid, width]; both weights have shape [modes, width, width]. The arbitrary-rank full-DFT FNO has a different parameterization and cannot share these weights.

    The four real matrix products implement ordinary complex multiplication, without conjugating the weight. Padding occurs after that multiplication, so discarded frequencies have no parameters. denseReference and automatic share a checkpoint. Only the transforms select native primitives; the tape composes their packed-real adjoints with the channel maps and indexing operations.

    Instances For