W3cubDocs

/TensorFlow Python

tf.keras.Input

Aliases:

  • tf.keras.Input
  • tf.keras.layers.Input
tf.keras.Input(
    shape=None,
    batch_size=None,
    name=None,
    dtype=None,
    sparse=False,
    tensor=None,
    **kwargs
)

Defined in tensorflow/python/keras/_impl/keras/engine/input_layer.py.

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.

For instance, if a, b and c are Keras tensors, it becomes possible to do: model = Model(input=[a, b], output=c)

The added Keras attribute is: _keras_history: Last layer applied to the tensor. the entire layer graph is retrievable from that layer, recursively.

Arguments:

  • shape: A shape tuple (integers), not including the batch size. For instance, shape=(32,) indicates that the expected input will be batches of 32-dimensional vectors.
  • batch_size: optional static batch size (integer).
  • name: An optional name string for the layer. Should be unique in a model (do not reuse the same name twice). It will be autogenerated if it isn't provided.
  • dtype: The data type expected by the input, as a string (float32, float64, int32...)
  • sparse: A boolean specifying whether the placeholder to be created is sparse.
  • tensor: Optional existing tensor to wrap into the Input layer. If set, the layer will not create a placeholder tensor.
  • **kwargs: deprecated arguments support.

Returns:

A tensor.

Example:

```python
# this is a logistic regression in Keras
x = Input(shape=(32,))
y = Dense(16, activation='softmax')(x)
model = Model(x, y)
```

Raises:

  • ValueError: in case of invalid arguments.

© 2018 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/keras/Input