I tried to save the text learner model in lesson 1, and I couldn’t figure out where the default save library is. I thought it would be in the same directory as where the jupyter notebook is, but it isn’t.
I’m running fastai2 off my own Ubuntu box. I tried
I have the same question. I tried to create a path named “Data” in working directory. Then I run learn.export(), the model automatically saves at Data/models. I move the model to another place then run the code again, error occurs. Also what’s the difference between learn.export and learn.save? They generate different kinds of models files, but what is the relationship of these files?
Export pickles the learner for deployment, it keeps track of various fastai internals to help. Save saves away the model weights and stats about the optimizer.
Hence why save saved it away to a models/ folder (because we’re working with training our models still) whereas export can be done to anywhere and won’t default to the models/ folder
In notebook 2, it just give me an error (running on paperspace)
AttributeError Traceback (most recent call last)
in
----> 1 learn.export()
/opt/conda/envs/fastai/lib/python3.7/site-packages/fastai2/learner.py in export(self, fname, pickle_protocol)
503 #To avoid the warning that come from PyTorch about model not being checked
504 warnings.simplefilter(“ignore”)
–> 505 torch.save(self, self.path/fname, pickle_protocol=pickle_protocol)
506 self.create_opt()
507 if state is not None: self.opt.load_state_dict(state)
/opt/conda/envs/fastai/lib/python3.7/site-packages/torch/serialization.py in save(obj, f, pickle_module, pickle_protocol, _use_new_zipfile_serialization)
326
327 with _open_file_like(f, ‘wb’) as opened_file:
–> 328 _legacy_save(obj, opened_file, pickle_module, pickle_protocol)
329
330
Seemed to be a temporary error.
Refreshing didn’t work, stop it running an restart didn’t work.
So I went back and ran through nb1 and then ran nb2 again. this time it worked. Might have been a file lock or something?