Edit: Ok, I THINK this is due to that ConvLearner.pretrained
is not actually using resnet34 straight, it seems to add some more layers to it so it will become a different network.
So either I have to figure out how to save the model architecture so I can load it in pytorch (I failed so far),
or
I have to figure out how to recreate the same kind of network in pytorch.
Anyone gone through this before?
If I look at the resnet34 model in fastai:
learn = ConvLearner.pretrained(resnet34, data, precompute=True) learn.model.state_dict()
it contains entries like this
OrderedDict([('0.weight',
0.0111
0.2668
0.8734
⋮
0.6134
0.2887
0.3314
[torch.cuda.FloatTensor of size 1024 (GPU 0)]), ('0.bias',
0
0
...
if I compare that to a resnet34 model created directly in pytorch
resnet34(True).state_dict()
it contains entries like this
OrderedDict([('conv1.weight', (0 ,0 ,.,.) = 5.4109e-03 -6.9092e-03 7.8839e-03 ... 4.9072e-02 3.0660e-02 2.5398e-02 4.1081e-02 3.1296e-02 3.2265e-02 ... 3.3145e-02 2.9754e-02 4.1735e-02 4.9519e-
This causes me problem when I want to train a model in fastai and use it in pytorch.
Anyone got an idea why the fastai state_dict has just prefix numbers like 0.weight
and not conv1.weight
?