Keras: __init__() got an unexpected keyword argument 'inputs'

Created on 2 May 2017  路  11Comments  路  Source: keras-team/keras

Hello.
I try to make a model on a functional API with the participation of recursive layers.

>>> inputs = Input( shape=( 4, ) )
>>> x = Reshape( ( 1, 4 ) )(inputs)
>>> x = normalization.BatchNormalization( batch_input_shape=(None, 1, 4) )(x)
>>> x = GRU( gru1 )(x) #, input_shape=(data_x.shape[1], data_x.shape[2])
>>> predictions = Dense( 1, activation='tanh' )(x)
>>> model = Model( inputs=inputs, outputs=predictions )
..
    model = Model( inputs=inputs, outputs=predictions )
TypeError: __init__() got an unexpected keyword argument 'inputs'

As far as I understood the problem in the line:
inputs = Input( shape=( 4, ) )

Tell me how you can solve the problem.
Thank you.

Most helpful comment

In case someone lands here now, this error comes up if you provide inputs argument and NOT the outputs argument. For example, you get this error if you mistype "output" instead of outputs. Red herring today.

All 11 comments

You need to update Keras to version 2 or higher in order to use the Keras 2 API.

@fchollet , I updated all the packages. And I use the documentation with keras.io

You definitely did not. Update Keras. Check that you are running with Keras 2 or higher.

I apologize for the time spent. I really did not update the Keras package correctly.

In case someone lands here now, this error comes up if you provide inputs argument and NOT the outputs argument. For example, you get this error if you mistype "output" instead of outputs. Red herring today.

I'm using keras version 2.2.4 in Anaconda and still facing the same issue.

I'm using keras version 2.2.4 in Anaconda and still facing the same issue.

Double check for typo on kwargs ... I hit the thing above many times and keep landing here.

My version of Keras is 2.2.4-tf. I have both the inputs and the outputs arguments defined, but still I am getting this error. Below is the code:
self.model = Model(inputs=[self.sequence, self.features], outputs=[logits])
The error I am getting is: __init__() got an unexpected keyword argument 'inputs'. Could someone help me understanding the issue?

did you solve it? @RishikMani

did you solve it? @RishikMani

@julka01 I was able to resolve the error. I was importing the class Model from Keras and at the same time had another custom class defined with the name of Model. I renamed my custom class afterward which it worked perfectly well.

I removed the inputs, outputs keywords and now model compiled correctly I'm using Keras version 2.3.1

Was this page helpful?
0 / 5 - 0 ratings