Introduction

The Sequential API is the simplest of the three ways to build a model in Keras, letting you define a neural network as a straightforward, linear stack of layers — data flows through each layer in exactly the order you add them, from input to output, with no branching, merging, or multiple inputs/outputs along the way. For the large share of everyday deep learning tasks that fit this simple, single-path structure, the Sequential API offers the fastest, most readable way to define a model.

As previewed in the general Keras overview, the Sequential API is typically the natural starting point for most Keras projects, with the Functional API and Model Subclassing reserved for cases where a linear stack of layers genuinely isn't sufficient to express the desired architecture.

Why Does the Sequential API Matter?

The Sequential API helps to:

  • Provide the simplest, most concise way to define a standard neural network
  • Make model architecture immediately readable — a clear top-to-bottom list of layers
  • Reduce boilerplate for the many tasks that fit a simple, linear layer structure
  • Serve as an accessible entry point for beginners learning Keras and deep learning
  • Cover the majority of common use cases without needing more complex APIs
  • Integrate seamlessly with the rest of the tf.keras workflow (compile, fit, evaluate, predict)

What "Sequential" Means

Whiteboard
Whiteboard diagram
"Sequential" means exactly what it sounds like: layers are
arranged in a straight, single-path sequence. Each layer takes
the output of the layer directly before it as its only input,
and passes its own output directly to the next layer — no
branches, no merges, no skipping ahead, and no multiple
separate inputs or outputs.

Building a Model with the Sequential API

This single, readable block defines a complete three-layer neural network — an input layer implicitly defined by input_shape, one hidden layer, and an output layer — in the exact order data will flow through them.

An Alternative Way to Build: Adding Layers Incrementally

Both approaches — passing a list of layers at once, or adding them one at a time with .add() — produce an identical model; the choice is purely a matter of style or when layers need to be added dynamically (e.g., in a loop).

The Full Sequential Workflow

Inspecting a Sequential Model

The .summary() method provides a quick, readable overview of every layer, its output shape, and its parameter count — extremely useful for verifying a model's structure matches what was intended before training.

What the Sequential API Cannot Do

Because it only supports one continuous, linear path of layers,
the Sequential API cannot express:

- Multiple separate inputs (e.g., combining text and image data)
- Multiple separate outputs (e.g., predicting two different things at once)
- Layers that need to skip ahead (e.g., residual/skip connections,
  as covered in earlier topics)
- Layers that merge or combine outputs from more than one
  previous layer (e.g., concatenating two branches)

Any of these situations require the Functional API or Model
Subclassing instead, both covered in the next topics.

Sequential API vs Functional API (Preview)

AspectSequential APIFunctional API
StructureSingle, linear stack of layersFlexible graph, supports branching/merging
Multiple Inputs/OutputsNot supportedSupported
Skip/Residual ConnectionsNot supportedSupported
ComplexitySimplest, most conciseMore flexible, slightly more verbose
Best ForStraightforward, single-path modelsMore complex architectures

(The Functional API is covered in full depth in the next topic.)

Key Properties of the Sequential API

  • The Sequential API defines a model as a strict, linear stack of layers with a single input and single output.
  • Layers can be defined all at once as a list, or added incrementally using .add().
  • The .summary() method provides a quick, readable overview of a model's architecture and parameter count.
  • The Sequential API cannot express multiple inputs/outputs, branching, merging, or skip connections.
  • It follows the same compile → fit → evaluate → predict workflow used throughout tf.keras.

Where Is the Sequential API Used?

FieldApplication
Basic Image ClassificationSimple CNN architectures with a straightforward layer stack
Tabular Data ModelingStandard feedforward networks for structured data
Educational/Learning ContextsThe most common starting point for teaching Keras fundamentals
Simple Time Series ForecastingBasic LSTM/Dense stacks for straightforward sequence tasks
Quick PrototypingRapidly testing a simple model structure before adding complexity

Advantages

  • Extremely simple, readable, and quick to write for standard model architectures
  • Requires minimal Keras/TensorFlow knowledge to get started
  • Covers a large share of common, everyday deep learning tasks
  • .summary() provides an easy way to verify model structure at a glance
  • Integrates seamlessly with the rest of the standard tf.keras workflow

Limitations

  • Cannot express multiple inputs, multiple outputs, or non-linear layer connections
  • Not suitable for architectures requiring skip/residual connections
  • Can feel restrictive once a project's complexity grows beyond a simple linear stack
  • Provides no way to reuse or share layers across different parts of a more complex model
  • Requires switching to the Functional API or Subclassing as soon as branching is needed

Real-World Examples

ApplicationSequential API Use
MNIST Digit ClassificationA classic, simple example of a Sequential CNN or Dense-based model
Basic Sentiment AnalysisA straightforward embedding + Dense layer stack
Simple Regression TasksA linear stack of Dense layers predicting a continuous value
Introductory Deep Learning CoursesThe default starting point for teaching model-building basics
Quick Baseline ModelsA fast way to establish a baseline before trying more complex architectures

Best Practices

  • Use the Sequential API as your default starting point for straightforward, single-path models.
  • Call .summary() early and often to verify your model's structure matches your intentions.
  • Switch to the Functional API as soon as you need multiple inputs/outputs or non-linear connections.
  • Keep layer ordering intentional and readable, since the Sequential API's clarity is its main strength.
  • Use the incremental .add() approach when layers need to be added dynamically or conditionally.

Interview Tip

A common interview question is:

"What are the limitations of the Sequential API, and when would you need to use the Functional API instead?"

A strong answer is:

The Sequential API can only express a single, linear stack of layers, where each layer has exactly one input and one output connecting directly to the next layer in sequence. This means it can't handle architectures with multiple separate inputs or outputs, layers that need to merge or combine outputs from different branches, or skip/residual connections like those used in ResNet or transformer architectures. Any of these situations require switching to the Functional API, which represents a model as a flexible graph of layers rather than a strict linear sequence, allowing much more complex, non-linear architectures to be expressed.

Naming specific unsupported cases (multi-input, skip connections) makes your answer stronger and more concrete.

Conclusion

The Sequential API offers the simplest, most readable way to build a standard neural network in Keras, ideal for the many tasks that fit a straightforward, single-path layer structure. With its clear limitations in mind — no branching, merging, or multiple inputs/outputs — the next topic explores the Functional API, which removes these restrictions to support far more flexible and complex model architectures