Hi, thank you for answering me. But, your way does not work. 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 12](http://pre-trained 6 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 model  instance attribute. As a result, they made an wrong prediction(correct index is 3).  I don’t know. The Resnet that fastai using is totally same as the Pytorch offical’s.
Link to notebook 8