I’d like to bring an attention to a proposal #6107.
AFAIK, the only way to share trained weights in pytorch is to use pickle, which is not safe at all. So I proposed a simple solution based on ONNX just to share weights.
Pros
- Safe
- Relies on already existing format with good tooling; needed protobuf-code is already in pytorch source. If needed, weights can be read from other languages
- Proposed implementation (see later) stores parameters that are met in the model state several times, loading does not break this situation (if parameters used the same tensor, they use the same tensor after loading)
- Proposed implementation was checked to normally import / export all (largest) torchvision models: inception_v3, alexnet, densenet201, resnet152, squeezenet1_1, vgg19_bn.
Cons
- No support for serialization of sparse tensors. AFAIK, ONNX has no support for SparseTensors so far.
Is there a better way to share trained models that I don’t know about?