Home

Awesome

functional-zoo

Model definitions and pretrained weights for PyTorch and Tensorflow

PyTorch, unlike lua torch, has autograd in it's core, so using modular structure of torch.nn modules is not necessary, one can easily allocate needed Variables and write a function that utilizes them, which is sometimes more convenient. This repo contains model definitions in this functional way, with pretrained weights for some models.

Weights are serialized as a dict of arrays in hdf5, so should be easily loadable in other frameworks. Thanks to @edgarriba we have cpp_parser for loading weights in C++.

More models coming! We also plan to add definitions for other frameworks in future, probably tiny-dnn first. Contributions are welcome.

See also imagenet classification with PyTorch demo.ipynb

Models

All models were validated to produce reported accuracy using imagenet-validation.py script (depends on OpenCV python bindings).

To load weights in Python first do pip install hickle, then:

import hickle as hkl
weights = hkl.load('resnet-18-export.hkl')

Unfortunately, hickle py3 support is not yet ready, so the models will be resaved in torch pickle format with torch.utils.model_zoo.load_url support, e.g.:

weights = model_zoo.load_url('https://s3.amazonaws.com/modelzoo-networks/wide-resnet-50-2-export-5ae25d50.pth')

Also, make_dot was moved to a separate package: PyTorchViz

Folded

Models below have batch_norm parameters and statistics folded into convolutional layers for speed. It is not recommended to use them for finetuning.

ImageNet

modelnotebookval errordownloadsize
VGG-16vgg-16.ipynb30.09, 10.69url coming528 MB
NINnin-export.ipynb32.96, 12.29url33 MB
ResNet-18 (fb)resnet-18-export.ipynb30.43, 10.76url42 MB
ResNet-18-ATresnet-18-at-export.ipynb29.44, 10.12url44.1 MB
ResNet-34 (fb)resnet-34-export.ipynb26.72, 8.74url78.3 MB
WRN-50-2wide-resnet-50-2-export.ipynb22.0, 6.05url246 MB

Fast Neural Style

Notebook: fast-neural-style.ipynb

Models:

modeldownloadsize
candy.hklurl7.1 MB
feathers.hklurl7.1 MB
wave.hklurl7.1 MB

Models with batch normalization

Coming