tf.keras.Input( shape=None, batch_size=None, name=None, dtype=None, sparse=False, tensor=None, ragged=False, **kwargs )
Input() is used to instantiate a Keras tensor.
A Keras tensor is a TensorFlow symbolic tensor object, which we augment with certain attributes that allow us to build a Keras model just by knowing the inputs and outputs of the model.
For instance, if
c are Keras tensors,
it becomes possible to do:
model = Model(input=[a, b], output=c)
shape=(32,)indicates that the expected input will be batches of 32-dimensional vectors. Elements of this tuple can be None; 'None' elements represent dimensions where the shape is not known.
sparseis False, sparse tensors can still be passed into the input - they will be densified with a default value of 0.
Inputlayer. If set, the layer will not create a placeholder tensor.
# this is a logistic regression in Keras x = Input(shape=(32,)) y = Dense(16, activation='softmax')(x) model = Model(x, y)
Note that even if eager execution is enabled,
Input produces a symbolic tensor (i.e. a placeholder).
This symbolic tensor can be used with other
TensorFlow ops, as such:
x = Input(shape=(32,)) y = tf.square(x)
batch_shape) are provided.