0

I am having trouble merging 2 models of multiple inputs. The 2 models both receive multiple inputs for multichannel CNN. But it's giving me the error - TypeError: unhashable type: 'list' when I tried to merge them. Any idea what I am doing wrong here? Thank you very much for your assistance in advance.

def mergeCnnModel(cnnModel, cnnModel2):
    merged = concatenate([cnnModel.layers[-2].output, 
    cnnModel2.layers[-2].output])
    dense1 = Dense(10, activation='relu')(merged)
    outputs = Dense(1, activation='sigmoid')(dense1)
    model = Model(inputs=[cnnModel.input, cnnModel2.input], outputs=outputs)
    # compile
    model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
    # summarize
    print(model.summary())
    return model

enter image description here

4
  • Can you provide the trace for the error? Commented Jun 2, 2018 at 8:58
  • Here's the trace Commented Jun 2, 2018 at 9:40
  • Can you try Model(inputs=cnnModel.inputs+cnnModel2.inputs, outputs=outputs)? The problem is passed model inputs. Commented Jun 2, 2018 at 9:45
  • It works, thank you very much Commented Jun 2, 2018 at 9:51

1 Answer 1

1

Converting comment into answer: The problem is passing list of lists as inputs to the final model. You need concatenate the individual input lists of sub models:

model = Model(inputs=cnnModel.inputs+cnnModel2.inputs, outputs=outputs)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.