-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I save a pyod model? #88
Comments
Agreed that a model save functionality should be added. Marked as a todo task. I am not sure whether pickle will work or not (hopefully yes), and I will also do some tests. |
When trying to save AutoEncoder model using Pickle, Following error occurs. Any idea how can I fix it? TypeError: can't pickle _thread.RLock objects
|
@epicsol-inc sorry for the late response. AE in pyod is written with keras, and saving the model can be tricky. To my understanding, keras models may not be pickable (keras-team/keras#10528)... If saving model is a must, you may have to copy the code out from auto_encoder.py directly. Sorry for the inconvenience.. |
@epicsol-inc
You can check if it works in your case |
@sbysiak Thanks for the note. Much appreciated. Will also check out it and consider add this to the documentation :) |
Any news regarding save PyOD models? I need to save an IForest model, can I use Pickle? |
Sorry I have not tested it out which should be. If pickle is not working, I will say using "https://pypi.org/project/dill/" as mentioned above. This will be listed on the top of my priority list now. |
I've used picke.dump and worked! |
I've also used pickle.dump() for the classifiers knn, oc-svm, iforest and fabod and it works saving and loading them with: save: pickle.dump(clf, open(folder + clf_name + '.h5', 'wb')) |
Pickle and dill can save successfully. But these formats can make it time consuming to load the model. For autoencoder model, I saved the weights as HDF5 and the classifier object as pickle for faster loads and less disk space.
##then set autoencoder model to None. It makes it smaller
Model Load##load the auto encoder instance
This works almost 5x faster and model size is 10X smaller. |
what is model_from_json? this https://www.tensorflow.org/api_docs/python/tf/keras/models/model_from_json ? |
I have tried with .pkl and .h5 extension along with dill, pickle and joblib but the issue persists
|
Hi! |
I've just trained a auto-encoder model, and I wonder how can I save the model so that I don't need to train it again next time I want it. I didn't see any function related to save a model in auto_encoder.py, so I'm not sure if there is a function which I can use to save my model. Do you implement this kind of function?
The text was updated successfully, but these errors were encountered: