Reputation: 5968
When should I use Input
and when should I use InputLayer
? In the source code there is a description, but I am not sure what it means.
InputLayer:
Layer to be used as an entry point into a graph. It can either wrap an existing tensor (pass an
input_tensor
argument) or create its a placeholder tensor (pass argumentsinput_shape
orbatch_input_shape
as well asdtype
).
Input:
Input()
is used to instantiate a Keras tensor. A Keras tensor is a tensor object from the underlying backend (Theano or TensorFlow), which we augment with certain attributes that allow us to build a Keras model just by knowing the inputs and outputs of the model.
Upvotes: 6
Views: 1838
Reputation: 416
InputLayer
is a callable, just like other keras layers, while Input
is not callable, it is simply a Tensor object.
You can use InputLayer
when you need to connect it like layers to the following layers:
inp = keras.layers.InputLayer(input_shape=(32,))(prev_layer)
and following is the usage of Input
layer:
x = Input(shape=(32,))
y = Dense(16, activation='softmax')(x)
model = Model(x, y)
Upvotes: 0
Reputation: 4348
I think InputLayer
has been deprecated together with the Graph models. I would suggest you use Input, as all the examples on the Keras documentations show.
Upvotes: 2