How to combine 2 prepared models in Keras
I want to merge the last layer before exiting the two trained models and create a new model that uses the merged layer for prediction. below are the relevant parts of my code:
model1 = load_model("model1_location.model")
model2 = load_model("model1_location.model")
merged_model = Sequential(name='merged_model')
merged_model.add(merge([model1.layers[-1],model2.layers[-1]]))
merged_model.add(Dense(3, activation='softmax'))
The above code gives the following error:
ValueError: Layer merge_2 was called with an input that isn't a symbolic tensor. Received type: <class 'keras.layers.core.Dense'>.
What is the correct way to combine these models, Alternatively how do I get the symbolic tensor from the layer?
+3
source to share