Unknown initializer: GlorotUniform when loading Keras model

Dhruvin modi picture Dhruvin modi · Nov 7, 2018 · Viewed 40.6k times · Source

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 trained model file and try to predict output on my laptop, I am getting error when loading the model.

Here is the code:

import tensorflow as tf
from tensorflow import keras
import h5py

# Initialization

loaded_model = keras.models.load_model('./train_personCount_model.h5')

And the error:

ValueError: Unknown initializer: GlorotUniform

Answer

Richar Fernandez Vilchez picture Richar Fernandez Vilchez · Feb 26, 2019

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')