What is the best way to save and retrain a model

I am trying to implement different training strategies/methods outlined in lesson 7. I want to build-up the model incrementally. For example, first train a model, then train the same model with progressive resizing, then with mix up…and so on. My first approach was to train a model, then export it and then reload in another notebook and train it again. I am trying to do this in kaggle with amazon-planets dataset. I used learn.export() to export a trained model but it turns out that this model cannot be reloaded again without the data that was used to train it. So, my question is what is the best way to pick up a model and train it more with a different method ? I would really appreciate any reponse regarding this. Thanks a lot.

You may want to use Learner.save and Learner.load for this purpose. Only once you complete the training process, Learner.export is used for inference purpose.

1 Like

Thank you for the response.

Does the saved model with learn.save persist out of the current session in Kaggle ? Do I have to run the dataloader again if I stop the session after saving model and restart it? I am goinf to try it but I want to know what I should expect.

Thanks !

You will have to recreate the data loader, yes. It is not saved with the model.

1 Like

Thanks!

I tried learn.save and it did save the model output but the output did not persist once I stopped the session in Kaggle. Do I need to save and commit the code if I want to load the model in next session?

Thanks!

This seems to be addressed in the kaggle forum

1 Like

@sophiagracia,

Thanks!