I am experimenting with lesson3: imdb notebook.
My language-model learner is trained and saved, the encoder is also saved (as ‘fine_tuned_enc’).
Now in the classification part of the notebook, where we create a text_classifier_learner, should I load ‘fine_tuned_enc’ using learner.load or leaner.load_encoder?
The notebook uses load_encoder initially but later after some freeze_to and trainings it uses learner.save and learner.load (not load_encoder). Hence the question.
When you are initializing the weights of your classifier, you should use load_encoder to load the language model you fine-tuned. Later, once you have fitted your model, you should use load.
@sgugger,
Thank you sir,
If one uses load_decoder, the prediction results are terrible.
For example:
learn.predict(“It was awful,terribly worse than I could have imagined”)>>(Category neg, tensor(0), tensor([0.5442, 0.4558]))
Hi @sam2 I woul like to know once I have exported the model in the export.pkl file, what code should I use to load in a new python file the model to make a classification of one review?
I tried:
from fastai2.vision.all import *
from fastai2.vision.widgets import *
from utils import *
learn = load_learner(path/‘export.pkl’, cpu=True)
learn.path = path
learn.predict(“you suck”)
FileNotFoundError: [Errno 2] No such file or directory: ‘you suck’