TorchLean API

NN.Runtime.Autograd.Model.Fno

Fourier Neural Operators over Arbitrary Spatial Rank #

This module implements a Fourier layer over any finite collection of spatial axes. The transform uses separable per-axis FFTs or an explicit dense reference. Its phase is the sum of per-axis phases, so this is the tensor-product multidimensional DFT rather than a one-dimensional DFT of flattened storage. Real and imaginary parts are represented by separate tensors, allowing the model to run over ordinary real scalar backends. The spectral linear map is applied independently at every retained frequency.

@[reducible, inline]

Shape of an m × n matrix.

Instances For
    @[reducible, inline]

    Shape of a vector with n entries.

    Instances For
      def Runtime.Autograd.Model.Layers.FNO.reshapeModesForMatmul (modes width : ) :
      Layer [modes, width] [modes, 1, width]

      Reshape [modes, width] for mode-wise batched matrix multiplication.

      Instances For
        def Runtime.Autograd.Model.Layers.FNO.restoreModesAfterMatmul (modes width : ) :
        Layer [modes, 1, width] [modes, width]

        Restore the matrix view produced by reshapeModesForMatmul.

        Instances For
          def Runtime.Autograd.Model.Layers.FNO.pointwiseAffine (grid inChannels outChannels : ) (weightSeed : := 0) :
          Layer [grid, inChannels] [grid, outChannels]

          Pointwise affine channel map over a flattened spatial grid.

          Instances For
            @[reducible, inline]

            Tensor shape spatial... × channels.

            Instances For
              @[reducible, inline]

              Tensor shape of a scalar field over the spatial grid.

              Instances For

                Number of spatial grid points.

                Instances For
                  @[reducible, inline]

                  Matrix view that flattens the spatial axes and preserves the channel axis.

                  Instances For
                    @[reducible, inline]

                    Learned frequency-wise channel maps, one channels × channels matrix per grid frequency.

                    Instances For

                      Decode a row-major flat index into coordinates for the given axis extents.

                      Instances For

                        Sum inputᵢ * frequencyᵢ / extentᵢ over matching spatial coordinates.

                        Instances For
                          def Runtime.Autograd.Model.Layers.FNO.Internal.phase {α : Type} [TorchLean.Storage α] [Context α] (extents : List ) (input frequency : ) :
                          α

                          Tensor-product DFT phase for two flattened spatial coordinates.

                          Instances For

                            Cosine part of the dense multidimensional DFT matrix.

                            Instances For

                              Negative-sine part of the dense multidimensional DFT matrix.

                              Instances For

                                Normalized cosine part of the dense multidimensional inverse DFT matrix.

                                Instances For

                                  Normalized sine part of the dense multidimensional inverse DFT matrix.

                                  Instances For

                                    Whether one coordinate lies in the retained low- or high-frequency bands.

                                    Instances For

                                      Test membership in the rectangular frequency set selected by modes.

                                      The flat index is decoded in the same outermost-first row-major order used by Shape.ofList.

                                      Instances For

                                        Pointwise mask for the retained multidimensional Fourier modes.

                                        Instances For
                                          def Runtime.Autograd.Model.Layers.FNO.Internal.flattenSpatial {d channels : } (spatial : TorchLean.Tensor [d]) :
                                          Layer (fieldShape spatial channels) (flatFieldShape spatial channels)

                                          Reshape a spatial field to its matrix view.

                                          Instances For
                                            def Runtime.Autograd.Model.Layers.FNO.Internal.restoreSpatial {d channels : } (spatial : TorchLean.Tensor [d]) :
                                            Layer (flatFieldShape spatial channels) (fieldShape spatial channels)

                                            Restore a matrix view to its spatial axes.

                                            Instances For

                                              Add the singleton channel axis used inside an FNO model.

                                              Instances For

                                                Remove the singleton channel axis after the output projection.

                                                Instances For
                                                  def Runtime.Autograd.Model.Layers.FNO.block {d : } (spatial modes : TorchLean.Tensor [d]) (width : ) (activation : Activation.Kind := Activation.Kind.tanh) (spectralRealSeed spectralImagSeed skipWeightSeed : := 0) (path : F.SpectralPath := F.SpectralPath.automatic) :
                                                  Layer (fieldShape spatial width) (fieldShape spatial width)

                                                  One multidimensional FNO block.

                                                  The first d axes are transformed. A learned channel map is applied at every retained frequency, the discarded frequency rectangle is set to zero, and a pointwise affine skip is added after the inverse transform.

                                                  Instances For