liveBook · Manning

Symbolic tensor

As explained in Deep Learning with Python, Third Edition

A tensor-like placeholder that encodes shape and dtype information without holding actual data values.

A symbolic tensor is a placeholder that carries shape and dtype information without containing actual data. It represents the future tensors a model will process. section 7.2.2

Following shape information through layers

In a Keras Functional model, keras.Input(shape=(3,)) creates a symbolic tensor with shape (None, 3) and dtype float32. Calling a Dense(64) layer on it returns another symbolic tensor with shape (None, 64). A final Dense(10) layer produces the model output, which can be passed with the input to keras.Model. section 7.2.2

Use symbolic tensors to:

  • Describe model inputs before supplying real arrays. section 7.2.2
  • Connect layers while tracking updated shape and dtype information. section 7.2.2
  • Build graph-shaped models with multiple inputs or 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")

A compact Functional API example shows symbolic input creation, layer composition, and model construction. section 7.2.2

How Deep Learning with Python, Third Edition covers it

How deep it goes
Defines shape and dtype propagation through layers, but does not contain or process actual data values.
Examples
Uses keras.Input, Dense layers, shape inspection, and a two-layer Functional model.
What you can do after
Build it from scratch by connecting Keras layers and declaring model inputs and outputs.
How it connects
Connects Keras layers, the Functional API, tensors, model graphs, and multi-input multi-output models.

Also explained in

Compare how 2 books explain symbolic tensor →

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.