Loading a pre-trained model, in general

Hello, my application involves training models on a GPU, packaging up the trained models, and doing prediction with them on a CPU that won’t have access to the data used in training.
I’ve trained a tabular_learner and a text_classifier_learner and saved both with .save.

What is the best practice for loading those pre-trained models on another machine that won’t have access to the data that was trained on, and will anything else be needed other than the generated .pth files?

My original approach (based on documentation, searching the forums) was to create another e.g. tabular_learner, then use .load(). However, instantiating the learner requires an e.g. TabularDataBunch, and filling it with data other than what was used in the training of the model causes an error.

Any help here would be appreciated.

I understand you tried to create a learner, THEN load() it.

Did you try:
learner = load_learner(path, export_file_name)

?

That’s how I did it with image classifier, not sure if it runs with Tabular Data though.

And don’t forget to export it beforehand. Check this tutorial.

2 Likes

Thank you, this was exactly what I was looking for.

Please share the correct url.This seems to not work now.Cheers!!!

1 Like

1 Like