PyTorch models as plain functions, not module soup
A grab-bag of pretrained vision models written the way PyTorch's autograd actually wants you to write them.

What it does
This repo rewrites standard CNN architectures—ResNet, VGG, NIN, Wide ResNet—as plain Python functions instead of the usual torch.nn.Module stack. You get the weights too, serialized in HDF5 so you can smuggle them into other frameworks without PyTorch’s blessing. There’s even a C++ parser for the weight files.
The interesting bit
The author, Sergey Zagoruyko, was early to the insight that PyTorch’s autograd makes the nn.Module ceremony optional. Sometimes you just want a function that takes a Variable and returns a Variable. The notebooks show what that looks like in practice, plus a fast-neural-style bonus round.
Key highlights
- Functional definitions for ResNet-18/34, Wide ResNet-50-2, VGG-16, NIN
- Pretrained ImageNet weights with reported validation errors (e.g. WRN-50-2 at 22.0% top-1)
- “Folded” variants with batch norm merged into conv layers for inference speed
- Fast neural style transfer models (candy, feathers, wave)
- HDF5 weight format with C++ loader; torch pickle format also available
make_dotvisualization spun off into the now-popular PyTorchViz package
Caveats
- Several download links are dead or marked “url coming” (notably VGG-16)
- Python 3 hickle support was broken at the time; repo pivoted to torch pickle format
- “Models with batch normalization” section is still listed as “Coming”
- Last meaningful update appears to be several years ago
Verdict
Worth a look if you’re studying how to strip PyTorch down to its autograd bones, or need to port weights somewhere weird. For production use, modern torchvision and timm have superseded this. The fast-neural-style notebooks may still amuse.