1

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.

SajanGohil
  • 960
  • 13
  • 26

1 Answers1

0

If you rename one of your layers, it could be problem. Stop renaming.

chan
  • 1
  • 2
    Hi, sorry but your answer is more suitable as a comment. If you think this is the exact issue, you can show some working example where renaming the input layer caused the error and not doing that solved it. That would make this a good or atleast a proper answer. – SajanGohil Jun 09 '21 at 04:14