TorchLean API

NN.API.Neural.Layers.Convolution

Convolution #

Arbitrary-rank convolution geometry and configuration records.

Kernel, stride, and padding shared by convolutional layers with different channel widths.

  • kernelSize : Tensor [d]

    Kernel extent along each spatial axis.

  • stride : Tensor [d]

    Step along each spatial axis.

  • padding : Tensor [d]

    Symmetric zero-padding along each spatial axis.

Instances For

    Output grid produced by this convolution geometry.

    Instances For

      Output grid produced when this geometry is used for transpose convolution.

      Instances For

        Unit-stride geometry with an odd kernel along each axis and padding equal to the kernel radius.

        Instances For

          Same-padding geometry preserves every input extent.

          Configuration shared by arbitrary-dimensional convolution layers.

          • outChannels :

            Number of output channels. Must be positive when the layer is validated.

          • kernelSize : Tensor [d]

            Kernel extent along each spatial axis.

          • stride : Tensor [d]

            Step along each spatial axis.

          • padding : Tensor [d]

            Symmetric zero-padding along each spatial axis.

          • weightInitialization : Init.Scheme

            Initialization scheme for the kernel weights.

          Instances For

            Output grid produced from an input grid by this convolution configuration.

            Instances For
              def TorchLean.nn.Internal.validateConvolution {d : } (inputChannels outputChannels : ) (input kernelSize stride output : Tensor [d]) (initialization : Init.Scheme) (kind : String) :

              Shared convolution checks using the output geometry computed by the caller.

              Instances For
                def TorchLean.nn.Convolution.Config.validate {d : } (config : Config d) (inputChannels : ) (input : Tensor [d]) (kind : String := "Conv") :

                Validate channel widths, spatial geometry, and kernel initialization.

                Instances For
                  def TorchLean.nn.Convolution.Geometry.convolution {d : } (geometry : Geometry d) (outChannels : ) :

                  Build a convolution configuration by adding an output-channel width to shared geometry.

                  Instances For
                    @[simp]
                    theorem TorchLean.nn.Convolution.Geometry.convolution_outChannels {d : } (geometry : Geometry d) (outChannels : ) :
                    (geometry.convolution outChannels).outChannels = outChannels

                    Adding an output width to a geometry keeps that width.

                    @[simp]
                    theorem TorchLean.nn.Convolution.Geometry.convolution_outputSpatial {d : } (geometry : Geometry d) (outChannels : ) (input : Tensor [d]) :
                    (geometry.convolution outChannels).outputSpatial input = geometry.outputSpatial input

                    The spatial grid is the geometry's, so a shape proof can be discharged from the geometry alone without unfolding the configuration the builder produced.

                    Configuration shared by arbitrary-dimensional transposed-convolution layers.

                    • outChannels :

                      Number of output channels. Must be positive when the layer is validated.

                    • kernelSize : Tensor [d]

                      Kernel extent along each spatial axis.

                    • stride : Tensor [d]

                      Step along each spatial axis.

                    • padding : Tensor [d]

                      Symmetric zero-padding along each spatial axis.

                    • weightInitialization : Init.Scheme

                      Initialization scheme for the kernel weights.

                    Instances For

                      Output grid produced from an input grid by this transpose-convolution configuration.

                      Instances For
                        def TorchLean.nn.TransposedConvolution.Config.validate {d : } (config : Config d) (inputChannels : ) (input : Tensor [d]) (kind : String := "ConvTranspose") :

                        Validate channel widths, spatial geometry, and kernel initialization.

                        Instances For

                          Build a transpose-convolution configuration from shared geometry.

                          Instances For
                            @[simp]
                            theorem TorchLean.nn.Convolution.Geometry.transposedConvolution_outChannels {d : } (geometry : Geometry d) (outChannels : ) :
                            (geometry.transposedConvolution outChannels).outChannels = outChannels

                            Same for the transpose direction: the requested output width survives.

                            @[simp]
                            theorem TorchLean.nn.Convolution.Geometry.transposedConvolution_outputSpatial {d : } (geometry : Geometry d) (outChannels : ) (input : Tensor [d]) :
                            (geometry.transposedConvolution outChannels).outputSpatial input = geometry.transposedOutputSpatial input

                            Reusing one geometry for both directions is only sound if each direction keeps its own output rule, and it does: the transpose configuration's grid is Geometry.transposedOutputSpatial, never the forward Geometry.outputSpatial.