I trained my CNN (VGG) through google colab and generated .h5 file. Now problem is, I can predict my output successfully through google colab but when i download that .h5 tr
I fixed the problem:
Before:
from keras.models import load_model
classifierLoad = load_model('model/modeltest.h5')
Works for me
import tensorflow as tf
classifierLoad = tf.keras.models.load_model('model/modeltest.h5')
I ran into the same issue. After changing:
from tensorflow import keras
to:
import keras
life is once again worth living.
from tensorflow.keras.initializers import glorot_uniform
loaded_model = tf.keras.models.load_model("pruned.h5",custom_objects={'GlorotUniform': glorot_uniform()})
this worked for me when importing tensorflow keras
if you are loading the architecture and weights separtly, while loading archtiecture of the model change :
models.model_from_json(json)
to :
tf.keras.models.model_from_json(json)
and the problem is solved
I had the same problem with a model built with tensorflow 1.11.0 (using tensorflow.python.keras.models.save_model) and loaded with tensoflow 1.11.0 (using tensorflow.python.keras.models.load_model).
I solved it by upgrading everything to tensorflow 1.13.1, after building the model again with the new version, I could load it without this error.
In either kaggle or colabs
tf.keras.models.load_model("model_path")
works well