Downsample got error when converting model to .pt using script method

The error comes from the torchvision itself:

attribute 'downsample' of type 'NoneType' is not usable in a script method (did you forget to add it __constants__?):
at /nfs/engine/rajagopalar/anaconda3/envs/torchExp/lib/python3.6/site-packages/torchvision/models/
        out = self.relu(out)

Original post is here --> original post

Thanks in advance!

This was a bug in torchvision, it’s fixed with this PR.

We’re working on pushing a new release soon that will include this fix (among many others!). To get the fix locally today, you can install torchvision master from source.

@driazati Thanks for your prompt reply
After adding __constant__ = ['downsample'] I got the error below:

RuntimeError: attempting to re-assign constant 'downsample' in WeakScriptModuleProxy


Are you on the latest version of PyTorch (v.1.3.0)? You can check with print(torch.__version__). WeakScriptModuleProxy was removed prior to the 1.3 release, so you may need to update to get the right fixes.

@driazati I’ll check my libtorch version,
Thanks for sharing !!!

1 Like