JanGe
JanGe

Reputation: 43

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!

Upvotes: 3

Views: 4008

Answers (2)

DataFramed
DataFramed

Reputation: 1631

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.

Upvotes: 2

Homer
Homer

Reputation: 408

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.

Upvotes: 3

Related Questions