timeseriesAI / tsai

Time series Timeseries Deep Learning Machine Learning Python Pytorch fastai | State-of-the-art Deep Learning library for Time Series and Sequences in Pytorch / fastai
https://timeseriesai.github.io/tsai/
Apache License 2.0
5.1k stars 639 forks source link

Load_learner_all() needs exact folder path as the one used with learn.save_all() #642

Closed alitirmizi23 closed 1 year ago

alitirmizi23 commented 1 year ago

when loading using load_learner_all, why does the function expect EXACT SAME directory name and path as when we saved it? If i rename the export folder to lets say "export1", it doesn't work. Same with the model folders inside the export folder. If you could help with this pls. I saved models/learners using learn.save_all(path=‘export/Model1’) etc. here Model1, Model2 mean different models/learners trained

oguiza commented 1 year ago

Hi @alitirmizi23, Load_learner_all() and learn.save_all() will be deprecated soon. When you finish training a model, I'd recommend you use fastai's standard learn.export() and load_learner().

PATH = Path('models')
PATH.mkdir(parents=True, exist_ok=True)
learn.remove_cbs(learn.cbs)
learn.export(PATH/'model.pkl')

Then you need to do:

from fastai.learner import load_learner
learn = load_learner(PATH/'model.pkl')

Please, try it and let me know if this works,

oguiza commented 1 year ago

Closing this issue due to lack of activity and progress. If necessary please, create a new one.