My model is an ensemble of 2 different keras models, the models are connected to same input layer and have 2 output layers when combined. Both models are pretrained and I am trying to create a parallel architecture. My architecture is: `
model_input = Input(shape=(224,224,3), name="model_input")
gender_model_copy.layers.pop(0)
color_model_copy.layers.pop(0)
color_model_ens1 = color_model_copy(model_input)
gender_model_ens1 = gender_model_copy(model_input)
model_f = Model(input=[model_input], output=[color_model_ens1,gender_model_ens1])
model_f.save('path')
`
The model gets compiled and I can make predictions as well but when I save it and try to reload it I get, I get:
ValueError: Invalid input_shape argument (None, 224, 224, 3): model has 0 tensor inputs.
Full trace: Github gist link .
I have a custom layer which I am adding by using custom_objects={'Scale':Scale()}
argument in keras.models.load_model
My keras version is 2.2.5 and tensorflow version is 1.15
EDIT : I realized that the problem was that I was making layers untrainable by layer.trainable=False
, without doing that I was able to load the models without the error. I would still like to know why that happens.
If you rename one of your layers, it could be problem. Stop renaming.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.