I tried to load an old pytorch version built model in pytorch 0.4 but I recieved this error on accessing the layers of model :
python3.6/site-packages/torch/nn/modules/batchnorm.py", line 53, in extra_repr
'track_running_stats={track_running_stats}'.format(**self.__dict__)
KeyError: 'track_running_stats'
I was able to successfully load my model in pytorch 0.3 (or 0.3.1)
Any idea how to load the model in 0.4 or I need to revert pytorch version back???
Also this seems to be a batchnorm issue, my model loads correctly, and I can access fully connected layer as well!
How did you save the model?
This workflow works for me:
In PyTorch 0.3.1.post3:
model = nn.BatchNorm1d(3)
torch.save(model.state_dict(), 'test.pt')
In PyTorch 0.4.0:
model = nn.BatchNorm1d(3)
model.load_state_dict(torch.load('test.pt'))
x = torch.randn(1, 3, 2)
model(x)
Did you save the complete model rather than its state_dict?
If so, you should get a warning:
SourceChangeWarning: source code of class ātorch.nn.modules.batchnorm.BatchNorm1dā has changed. you can retrieve the original source code by accessing the objectās source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
Hello, did anyone here get already solution? I have a model is trained on Pytorch 0.3 and I couldnāt afford to retrain on 0.4. I have the same problem that it is complained that the BatchNorm2d doesnāt have the attribute: ātracking_running_stateā. Is this a way that I could filter out the module is BatchNorm and add this attribute myself? Or any better ideas? Thanks in advance. My model is saved the whole model.