Might be interesting to take a look at the code on github to get a deeper understanding. They seem to be used interchangeably, and to a certain degree they are, but they are not exactly the same thing.
First, InputLayer
class InputLayer(base_layer.Layer):
"""Layer to be used as an entry point into a Network (a graph of layers).
InputLayer is-a Layer in Object-Oriented speak. It extends the base class, meaning it has the ability to carry Layer state through inherited attributes and act as a Layer using inherited behavior. Down in the body of the init function is where one of the attributes gets instantiated…
input_tensor = keras_tensor.keras_tensor_from_type_spec(type_spec)
So an instance of InputLayer is-a Layer and has-a input_tensor
Next, Input.
def Input(
shape=None,
batch_size=None,
name=None,
dtype=None,
sparse=None,
tensor=None,
ragged=None,
type_spec=None,
**kwargs,
):
"""`Input()` is used to instantiate a Keras tensor.
Notice that Input is not a class. It is a function. It has neither Layer-like state nor Layer-like behavior of its own. What it does do can be found down near the end of the function…
input_layer = InputLayer(**input_layer_config)
# Return tensor including `_keras_history`.
# Note that in this case train_output and test_output are the same pointer.
outputs = input_layer._inbound_nodes[0].outputs
if isinstance(outputs, list) and len(outputs) == 1:
return outputs[0]
else:
return outputs
It calls the constructor for InputLayer, and returns its outputs. From this you can see why usage of the two looks similar. InputLayer instantiates the object instance directly, using its init(). Input isn’t itself a class; you don’t instantiate an Input object. Instead, Input instantiates an InputLayer indirectly and returns the InputLayer object’s output attribute, which is what you need to start wiring together the model. Hope this helps.