Convolutional PyTorch Reference Export #
PyTorch exporter for the two-block convolutional round-trip reference model.
The Lean configuration is rank-parametric. PyTorch itself exposes separate Conv1d, Conv2d, and
Conv3d classes, so that distinction is introduced only while rendering the external Python code.
The generated model has two convolution, ReLU, and max-pool blocks followed by Flatten and one
Linear head.
Rank-parametric configuration for a PyTorch convolution layer.
- inputChannels : ℕ
Input channels (
in_channels). - outputChannels : ℕ
Output channels (
out_channels). - kernel : TorchLean.Tensor ℕ [spatialRank]
Kernel extent along each spatial axis.
- stride : TorchLean.Tensor ℕ [spatialRank]
Stride along each spatial axis.
- padding : TorchLean.Tensor ℕ [spatialRank]
Zero-padding along each spatial axis.
Instances For
Rank-parametric configuration for a PyTorch max-pooling layer.
- kernel : TorchLean.Tensor ℕ [spatialRank]
Pooling-window extent along each spatial axis.
- stride : TorchLean.Tensor ℕ [spatialRank]
Stride along each spatial axis.
- padding : TorchLean.Tensor ℕ [spatialRank]
Zero-padding along each spatial axis.
Instances For
Configuration for the 2-block CNN exporter.
- className : String
Class name to use in the generated Python.
- inputChannels : ℕ
Input channels.
- inputSpatial : TorchLean.Tensor ℕ [spatialRank]
Input extent along each spatial axis.
- firstConvolution : ConvolutionConfig spatialRank
First convolution.
- firstPooling : PoolingConfig spatialRank
First pooling layer.
- secondConvolution : ConvolutionConfig spatialRank
Second convolution.
- secondPooling : PoolingConfig spatialRank
Second pooling layer.
- flattenedWidth : ℕ
Flattened feature count consumed by the linear head.
- outputWidth : ℕ
Output width of the linear head.
Instances For
Render a tensor shape as a Python tuple.
Instances For
Generate a Python CNN module plus a helper that loads explicit weights from string literals.
This is mainly used for examples: you can paste JSON/Lean-rendered weight arrays into Python and run the model without writing an extra serializer.