liveBook · Manning

Graph

As explained in Deep Learning with Python, Third Edition

A node-and-edge structure used here to represent how model layers are connected, including branches and merges.

A graph represents a model whose layers do not form one straight chain. Nodes and connections capture multiple inputs, multiple outputs, branches, merges, and other nonlinear topologies. section 7.2.2

Ticket-priority and routing model

Three inputs—ticket title, body, and tags—merge through Concatenate into shared features. Those features then branch into priority and department outputs, forming a multi-input, multi-output graph. section 7.2.2

Use the graph view to:

  • Connect layers by calling them on symbolic tensors, which carry shape and dtype specifications without containing actual data. section 7.2.2
  • Inspect layer inputs and outputs to understand how branches and merges are wired. section 7.2.2
  • Plot the model with layer names and shape information when checking its topology. section 7.2.2
Listing 7.9 A multi-input, multi-output Functional model
vocabulary_size = 10000
num_tags = 100
num_departments = 4

title = keras.Input(shape=(vocabulary_size,), name="title")              #1
text_body = keras.Input(shape=(vocabulary_size,), name="text_body")       #1
tags = keras.Input(shape=(num_tags,), name="tags")                        #1

features = layers.Concatenate()([title, text_body, tags])                #2
features = layers.Dense(64, activation="relu", name="dense_features")(features)                                         #3

priority = layers.Dense(1, activation="sigmoid", name="priority")(features)#4
department = layers.Dense( #4
    num_departments, activation="softmax", name="department"           #4
)(features)                                                            #4
 #5
model = keras.Model(                                                  #5
    inputs=[title, text_body, tags],                                   #5
    outputs=[priority, department],                                    #5
)                                                                      #5

Browse a concrete graph with three inputs, a merged feature path, and two output branches. section 7.2.2

How Deep Learning with Python, Third Edition covers it

How deep it goes
Explains graph construction through symbolic tensors, layer connections, model inputs and outputs, and topology plotting.
Examples
Uses a ticket classifier with three inputs, concatenated features, and priority and department outputs.
What it assumes
Assumes the limitations of sequential layer stacks while introducing symbolic tensors and graph-based model construction.
What you can do after
Apply it via Keras Functional API to build, inspect, and plot models with branches, merges, and multiple outputs.
How it connects
Connects the Functional API, Sequential model, symbolic tensor, and multi-input multi-output model.

Also explained in

Compare how 21 books explain graph →

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.