CNN PyTorch Reference Export #
PyTorch exporter for the 2-block ConvNet round-trip reference model.
This exporter is meant to mirror the "reference CNN example" shape that shows up in many TorchLean
examples: two Conv2d + ReLU + MaxPool2d blocks, then Flatten, then a single Linear head.
Instead of taking a long positional list of naturals, we use small configuration records so call sites stay readable and it's easy to extend the shape later.
Configuration for the 2-block CNN exporter.
- className : String
Class name to use in the generated Python.
- inputC : ℕ
Input image channels.
- inputH : ℕ
Input image height.
- inputW : ℕ
Input image width.
- conv1 : Conv2dCfg
conv 1.
- pool1 : MaxPool2dCfg
pool 1.
- conv2 : Conv2dCfg
conv 2.
- pool2 : MaxPool2dCfg
pool 2.
- flatSize : ℕ
flat Size.
- fcOut : ℕ
fc Out.
Instances For
Render the 2-block CNN as a Python nn.Module class definition.
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.