liveBook · Manning

Functional API

As explained in Deep Learning with R, Third Edition

The Keras Functional API is an interface for constructing models by connecting layer operations as a directed computation graph.

The Keras Functional API constructs models by connecting layer operations as a directed graph. It extends beyond Sequential models, which are limited to simple one-input, one-output stacks. section 3.6.3 section 7.2.2

A two-layer Functional model

inputs <- keras_input(shape = c(3), name = "my_input") features <- inputs |> layer_dense(64, activation = "relu") outputs <- features |> layer_dense(10, activation = "softmax") model <- keras_model(inputs = inputs, outputs = outputs, name = "my_functional_model") keras_input() creates a symbolic tensor containing shape and dtype specifications rather than data. Calling layers on it produces new symbolic tensors; keras_model() then binds the declared inputs and outputs. section 7.2.2

Use the API when the model requires graph structure rather than a flat layer sequence:

  • Combine Functional models with Sequential components, subclassed layers, or subclassed models. section 7.2.4
Figure 7.1 Progressive disclosure of complexity for model building
figure

Compare Sequential, Functional API, and model subclassing as progressively more flexible model-building workflows. section 7.2

How Deep Learning with R, Third Edition covers it

How deep it goes
Explains symbolic tensors, layer connections, model construction, inspection, plotting, and intermediate reuse, but defers full training-loop implementation.
Examples
Demonstrates a two-Dense model, a ticket-priority classifier, model plots, intermediate-output reuse, and mixed Functional-subclassed models.
What it assumes
Assumes familiarity with Sequential models, Dense layers, and compile(), fit(), evaluate(), and predict(); teaches symbolic tensors explicitly.
What you can do after
Build it from scratch by declaring symbolic inputs, connecting layers, binding outputs, training with named inputs, and inspecting or reusing graph components.
How it connects
Connects Sequential models, model subclassing, symbolic tensors, multi-task learning, feature extraction, and model visualization.

Also explained in

Compare how 3 books explain Functional API →

Related concepts

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