Convolutional Classifier #
The classifier accepts any batchShape and number of spatial axes. Each stage independently
configures its convolution, activation, optional dropout, and pooling. The linear head consumes
the final feature map; an empty stage list applies the head directly to the flattened input.
Configuration for a convolutional classifier over d spatial axes.
- inputChannels : ℕ
Number of channels in each input sample.
Extent of each spatial axis.
- stages : List (ConvPoolBlock.Config d)
Ordered convolution/activation/pooling stages.
- classCount : ℕ
Number of classifier logits per sample.
Instances For
def
TorchLean.nn.models.cnn
{d : ℕ}
(config : CNN.Config d)
(batchShape : Shape := [])
:
Builder (Sequential (config.inputShape batchShape) (config.outputShape batchShape))
Build the configured feature stages, flatten their output, and apply the linear head.
Instances For
def
TorchLean.nn.models.cnn.buildStages
{d : ℕ}
(config : CNN.Config d)
(batchShape : Shape)
(channels : ℕ)
(spatial : Tensor ℕ [d])
(stages : List (ConvPoolBlock.Config d))
:
Builder (Sequential (batchShape.concat ((spatial.to Shape).prependDim channels)) (config.outputShape batchShape))