liveBook · Manning

Input

As explained in Deep Learning with Python, Third Edition

A Keras constructor used to create symbolic input objects that specify the expected shape and dtype of model inputs.

Input is the Keras constructor that declares what a model will receive before real data is available. It creates a symbolic tensor: an object carrying input shape and dtype information, but no actual values. Layers can consume this object to build a model graph, making Input especially useful when a model has multiple inputs, multiple outputs, or a nonlinear topology. section 7.2.2

A two-layer Functional model

inputs = keras.Input(shape=(3,), name="my_input") features = layers.Dense(64, activation="relu")(inputs) outputs = layers.Dense(10, activation="softmax")(features) model = keras.Model(inputs=inputs, outputs=outputs, name="my_functional_model") Here, shape=(3,) describes each input example, while the symbolic tensor carries a batch-inclusive shape of (None, 3) and a float32 dtype. Each layer returns another symbolic tensor with updated specifications, and Model connects the declared input to the final output. section 7.2.2

Use Input when you need to:

  • Declare a model's input shape in advance so a Sequential model builds immediately and summary() can show layer shapes while layers are added. section 7.2.1
  • Name input objects for clearer model graphs and for matching named input arrays when training multi-input models. section 7.2.2
  • Declare several inputs, such as title, text body, and tags, then connect them through shared layers to multiple outputs. section 7.2.2
Listing 7.8 A simple Functional model with two Dense layers
inputs = keras.Input(shape=(3,), name="my_input")
features = layers.Dense(64, activation="relu")(inputs)
outputs = layers.Dense(10, activation="softmax")(features)
model = keras.Model(inputs=inputs, outputs=outputs, name="my_functional_model")

Inspect the complete minimal example: Input declares the symbolic starting point, Dense layers transform it, and Model binds inputs to outputs. section 7.2.2

How Deep Learning with Python, Third Edition covers it

How deep it goes
Defines shape, dtype, naming, symbolic propagation, and multi-input use, but does not detail Input implementation internals.
Examples
Uses a two-Dense-layer classifier, a three-input ticket model, and an advance-shaped Sequential model.
What it assumes
Assumes familiarity with Keras layers and models while clarifying symbolic tensors from the ground up.
What you can do after
Build Functional and prebuilt Sequential models by declaring input specifications before supplying data.
How it connects
Connects symbolic tensors with Keras layers, the Functional API, Sequential models, and the Model constructor.

Also explained in

Compare how 2 books explain Input →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with Python, Third Edition. The section links point to the parts of the book it draws on.