You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would use pickle. Although I have only lightly used PyBrain, pickle should almost always work. I have an example with your code: import pickle (rest of your imports and code before pickling) trainer = BackpropTrainer(fnn,dataset=trndata,verbose=True) f=open("your_file.pd",'wb') pickle.dump(trainer,f) f.close()
This will save your trainer. To load it: import pickle,BackpropTrainer f=open("your_file.pd",'rb') trainer=pickle.load(f) f.close()
In order to load the trainer the BackpropTrainer will have to be imported before unpickling. I haven't tested this code, but it should work.
Note that the "pickle module is not secure against erroneous or maliciously constructed data."(Python Docs)
If you are only saving it for yourself it's fine, but be careful otherwise. See the Python Docs or SO
Of course, it would be very nice to have a serialization exclusively for your trainer, but I have only lightly used Pybrain and know of no serialization. Pickle is what I would use for most of the code I write.
Now, I have trained my DIY net. How can I save it, so that I can use it again sometimes?
trainer = BackpropTrainer(fnn,dataset=trndata,verbose=True)
save up trainer.
The text was updated successfully, but these errors were encountered: