You can link your Google Drive to store files:
mount_location = "/gdrive"
# Mount Google Drive
from google.colab import drive
drive.mount(mount_location)
then, when training your model, you can use callbacks to save your model after every epoch, or only keep the best model:
learn.fit_one_cycle(
7,
callbacks=[SaveModelCallback(learn, every='improvement', name='best_so_far')]
)
Additionally, some debug code for when the link between Google Drive and Google Colab gives you a hard time:
## TroubleShooting helpers
# Uncomment and run the line below if you are having trouble (re)mounting Google Drive.
drive.mount("/gdrive", force_remount=True)
# Uncomment and run the line below if you want to remove all writes to Google Drive and unmoun the folder
drive.flush_and_unmount()