Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keras Model Multi Input - TypeError: ('Keyword argument not understood:', 'input')

I am trying to build a CNN that receives multiple inputs and I am trying the following:

input = keras.Input()
classifier = keras.Model(inputs=input,output=classifier)

When run the code I am receiving the following error for line 6 though:

TypeError: ('Keyword argument not understood:', 'input').

A hint would be much appreciated, thank you!

like image 564
JanGe Avatar asked Aug 13 '26 06:08

JanGe


2 Answers

Some parameters of your code are not specified. I have copied your example with some numbers that you can change back.

import keras

input_dim_1 = 10
input1 = keras.layers.Input(shape=(input_dim_1,1))
cnn_classifier_1 = keras.layers.Conv1D(64, 5, activation='sigmoid')(input1)
cnn_classifier_1 = keras.layers.Dropout(0.5)(cnn_classifier_1)
cnn_classifier_1 = keras.layers.Conv1D(48, 5, activation='sigmoid')(cnn_classifier_1)
cnn_classifier_1 = keras.models.Model(inputs=input1,outputs=cnn_classifier_1)

Some things to note

  1. The imports of your layers were not right. You need to import the layers/models you want from the right places. You can check my code against yours to see this.
  2. With the functional API of keras you do not need to specify the input shape as you have done in the first Conv1D layer. This is handled automatically.
  3. You need to correctly specify the keywords in Model. Specifically inputs and outputs. Different versions of keras use input / output or inputs/outputs as keywords for the call of the class Model.
like image 130
Homer Avatar answered Aug 15 '26 21:08

Homer


Hey, its simple, use following code:

classifier = keras.Model(input, classifier)

instead of calling

classifier = keras.Model(inputs = input, output = classifier)

Issue seems to come from latest versions of keras implementation.

like image 26
DataFramed Avatar answered Aug 15 '26 20:08

DataFramed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!