So I'm trying to load a model using:
learn = create_cnn(data, models.resnet50, lin_ftrs=[2048], metrics=accuracy)
learn.clip_grad();
learn.load(f'{name}-stage-2.1')
But I get the following error
RuntimeError: Error(s) in loading state_dict for Sequential:
size mismatch for 1.8.weight: copying a param with shape torch.Size([5004, 2048]) from checkpoint, the shape in current model is torch.Size([4542, 2048]).
size mismatch for 1.8.bias: copying a param with shape torch.Size([5004]) from checkpoint, the shape in current model is torch.Size([4542]).
The only thing that is different thing is that I added a random validation split that wasn't there in the stage-2.1
model, when I remove the split and have no validation set as the stage-2.1
was trained all goes well.
Whats happening?
A GPU-optimized computer vision library which can be extended in pure Python. An optimizer which refactors out the common functionality of modern optimizers into two basic pieces, allowing optimization algorithms to be implemented in 4–5 lines of code.
Use cnn_learner
method and latest Pytorch
with latest FastAI
. There was a breaking change
and discontinuity so you suffer now.
The fastai website has many examples such as this one
.
learn = cnn_learner(data, models.resnet50, metrics=accuracy)
Actually your torch.Size([5004, 2048]) from checkpoint, the shape in current model is torch.Size([4542, 2048]) you have to change it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With