How to save model in specified path?

Is it possible to specify path where I want to save my working model?

A week or two ago I could easily save the model on Paperspace but now for some reason learn.export() is failing with following error:

Error: Read-only file system: ‘/storage/data/camvid_tiny/export.pkl’

I believe that is because data for bear model came from internet whereas data for most most nbs is from /data folder inside storage which is read-only.

I was able to set path using but the export after setting path only works for some models. I wonder why?

learn.path = XYZ

You can pass the path parameter to the Learner constructor. Or if you are using a factory method like cnn_learner() you can pass it there as well. Then the export function takes an fname parameter (export.pkl by default) and path/fname is the location it tries to save at.

As for working only on some models you have to give us more details than that. What models don’t work? What error are you getting?

1 Like

This trick worked for me to store the model at desired location

learn.path = Path(’/storage’)
learn.model_dir = ‘ssr_models’
learn.save(’‘1epoch’)