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 function being differentiated.

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

Restore discarded frequencies as zeros before the inverse transform.

Instances For
    def Runtime.Autograd.Model.F.Fourier.spectralConv1dRfftReference {α : Type} [TorchLean.Storage α] [Context α] {m : TypeType} [Monad m] [Ops m α] {grid width modes : } (hmodes : modes grid / 2 + 1) (x : RefTy m α [grid, width]) (realWeight imagWeight : RefTy m α [modes, width, width]) :
    m (RefTy m α [grid, width])

    Dense reference for the cuFFT spectral primitive, with exactly the same weight layout.

    The four real matrix products implement ordinary complex multiplication, without conjugating the weight. Padding occurs after that multiplication, so discarded frequencies have no parameters.

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

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

      Inputs and outputs have shape [grid, width]; real and imaginary weights both have shape [modes, width, width]. denseReference and automatic can share a checkpoint directly. The arbitrary-rank full-DFT FNO uses a different parameterization and cannot share these weights.

      Instances For