with open(\'2model.json\',\'r\') as f:
json = f.read()
model = model_from_json(json)
model.load_weights(\"color_tensorflow_real_mode.h5\")
I traine
I had similar error (Unknown layer:name) when I was trying to locally load model trained on Colab. I was trying to change keras version, tensorflow version, conda version etc. and nothing helped. I solved this by saving my model's weights on Colab, locally creating the same model and loading the weights to this model.
load the model using
from tensorflow.keras.models import load_model
instead of
from keras.models import load_model
I tried using many methods but this is the one that finally worked!
Make sure you have the newest version of Keras
and tensorflow
(which are 2.4.4
and 1.11.0
) by running either pip install keras tensorflow
or conda install keras tensorflow
.
In case it is Google Colab that uses deprecated objects, you may need to use custom objects:
from keras.utils import CustomObjectScope
from keras.initializers import glorot_uniform
with CustomObjectScope({'GlorotUniform': glorot_uniform()}):
model = load_model('my_model.h5')
Not sure if this is your case though.