Convolutional Network Specifications #
This module defines a two-block convolutional network over an arbitrary number of spatial axes. Its spatial parameters are vectors, so the same model definition applies to sequence, image, volume, and higher-rank data. The forward and reverse-mode specifications use the generic convolution and pooling operations.
This is a standalone reference model. The executable nn.models.cnn accepts independently
configured stages, and NN/Runtime/PyTorch/Export/CNN.lean renders its own configuration.
Neither is constructed from this specification, and no equivalence theorem connects them here.
Spatial shape after one convolution followed by one pooling operation.
Instances For
Spatial shape after two convolution-pooling blocks.
Instances For
Feature-map shape after the second pooling operation.
Instances For
Number of scalar features presented to the linear head.
Instances For
Hyperparameters for a two-block convolutional network of spatial rank d.
- conv1Channels : ℕ
- conv2Channels : ℕ
- outputSize : ℕ
- kernel : TorchLean.Tensor ℕ [d]
- conv1Stride : TorchLean.Tensor ℕ [d]
- conv1Padding : TorchLean.Tensor ℕ [d]
- conv2Stride : TorchLean.Tensor ℕ [d]
- conv2Padding : TorchLean.Tensor ℕ [d]
- poolKernel : TorchLean.Tensor ℕ [d]
- poolStride1 : TorchLean.Tensor ℕ [d]
- poolPadding1 : TorchLean.Tensor ℕ [d]
- poolStride2 : TorchLean.Tensor ℕ [d]
- poolPadding2 : TorchLean.Tensor ℕ [d]
Instances For
Conditions needed by convolutional and pooling implementations.
Instances For
The default configuration at any spatial rank.
Instances For
The default configuration is well formed.
A generic two-block convolutional network with an explicit linear head.
- conv1 : Spec.ConvSpec d inChannels config.conv1Channels config.kernel config.conv1Stride config.conv1Padding α
- conv2 : Spec.ConvSpec d config.conv1Channels config.conv2Channels config.kernel config.conv2Stride config.conv2Padding α
- pool1 : Spec.MaxPoolSpec d config.poolKernel config.poolStride1 config.poolPadding1 ⋯ ⋯
- pool2 : Spec.MaxPoolSpec d config.poolKernel config.poolStride2 config.poolPadding2 ⋯ ⋯
- head : Spec.LinearSpec α (Cnn.featureSize config.conv2Channels spatial config.kernel config.conv1Stride config.conv1Padding config.conv2Stride config.conv2Padding config.poolKernel config.poolStride1 config.poolPadding1 config.poolStride2 config.poolPadding2) config.outputSize
Instances For
Parameter gradients for Model.
- conv1Kernel : TorchLean.Tensor α (Spec.Shape.ofList (config.conv1Channels :: inChannels :: config.kernel.to (List ℕ)))
- conv1Bias : TorchLean.Tensor α [config.conv1Channels]
- conv2Kernel : TorchLean.Tensor α (Spec.Shape.ofList (config.conv2Channels :: config.conv1Channels :: config.kernel.to (List ℕ)))
- conv2Bias : TorchLean.Tensor α [config.conv2Channels]
- headWeight : TorchLean.Tensor α [config.outputSize, Cnn.featureSize config.conv2Channels spatial config.kernel config.conv1Stride config.conv1Padding config.conv2Stride config.conv2Padding config.poolKernel config.poolStride1 config.poolPadding1 config.poolStride2 config.poolPadding2]
- headBias : TorchLean.Tensor α [config.outputSize]
Instances For
Forward pass for Model.
Instances For
Reverse-mode parameter and input derivatives for Model.