How to load fastai's pth file into the plain Pytorch?

It looks like there are many hack around to do that, but I have tried them, and they all failed.
pth from lesson1: https://drive.google.com/file/d/1KQPYLBzArw77e7PfHQ1W5kl5DWyqyUat/view?usp=sharing

It looks like that it is very complicated that the model’s head was removed …

It looks like once it is using learn.module, it will fail to correctly predict the true value, even though the original fastai model has high accuracy.

[https://drive.google.com/drive/u/0/folders/1vGgwkDCDMb5L8z6SgE1LDor6PhBeGmuW](http://pre-trained model)
data_set

In [304]:
print(np.argmax((model_pkl(intput.cuda() )).cpu().detach().numpy()   ))
print(((model_pkl(intput.cuda() )).cpu().detach().numpy()   ))
0
[[ 2.419829 -0.988511 -0.085516 -0.889875]]
In [0]:
learn_pth = learn.load('/content/drive/My Drive/fastai-v3/data/Trained Happy Sugar Life/stage-2').model;
learn_pth.eval()
In [303]:
print(np.argmax((learn_pth(intput.cuda() )).cpu().detach().numpy()   ))
print(((learn_pth(intput.cuda() )).cpu().detach().numpy()   ))
0
[[ 2.419829 -0.988511 -0.085516 -0.889875]]
In [301]:
pred_class,pred_idx,outputs = learn_pkl.predict(img_it)
print(pred_class)
print(pred_idx)
print(outputs)
shouko
tensor(3)
tensor([2.0889e-05, 3.8629e-11, 2.9075e-07, 9.9998e-01])
In [305]:
pred_class,pred_idx,outputs = learn.predict(img_it)
print(pred_class)
print(pred_idx)
print(outputs)
shouko
tensor(3)
tensor([2.0889e-05, 3.8629e-11, 2.9075e-07, 9.9998e-01])

The last two tests are testing loading pth and pkl and their output value. Their output value are same, but they are so different when they are using the learn.model. As a result, they made a wrong prediction(correct index is 3). I don’t know. The Resnet that fastai using is not totally same as the Pytorch offical’s.

Link to notebook