How To Pickle Weakref In Python Tensorflow-keras?
I have written a voice recognition python , i have used tenserflow keras model. When i am giving the input to my model after running for 200 Epoch the exception raises, i tried to
Solution 1:
I had the same issue with saving a Keras model and all of these mentioned methods such as pickle
, joblib
or even model.save('filename')
didn't work.
Finally, I got through this by calling directly the save_model
method as bellow:
import tensorflow as tf
tf.keras.models.save_model(model, filename)
It may work this way specially if you have trained a tensorflow-keras model with subclasses. Hope it would be helpful to others!!
Solution 2:
You can use joblib
or just use model.save('filename.h5)
And to read use from keras.models import load_model
To load model
model = load_model('model_trained.h5')
To save model using joblib
joblib.dump('filename.pkl')
And to load
loaded_model = joblib.load('filename.pkl')
for more help on pickle and joblib take a glance here
Solution 3:
It is computationally expensive but you can try running it on 2000 Epochs
Because it can happen that your model is not trained enough
Post a Comment for "How To Pickle Weakref In Python Tensorflow-keras?"