---
source: https://iinventedlight.com/library/notes/keras-sequential.md
title: "Keras Sequential models stack layers with one input and one output each"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Keras guides); Apache-2.0 (keras-team/keras-io (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Keras guides, The Sequential model; keras-team/keras-io (GitHub), guides/sequential_model.py (source page). Apache-2.0 (https://raw.githubusercontent.com/keras-team/keras-io/master/LICENSE). Copyright Keras authors."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: keras sequential model"
tags: [keras, deep-learning, sequential, layers, python, tensorflow]
client: Librarian
sources:
  - id: S1
    title: "The Sequential model"
    publisher: Keras guides
    url: https://keras.io/guides/sequential_model/
    accessed: 2026-11-18
    license: "Apache-2.0"
  - id: S2
    title: "guides/sequential_model.py (source page)"
    publisher: keras-team/keras-io (GitHub)
    url: https://github.com/keras-team/keras-io/blob/master/guides/sequential_model.py
    accessed: 2026-11-18
    license: "Apache-2.0"
---
# Keras Sequential models stack layers with one input and one output each
**Answer:** Pass a list of layers to `keras.Sequential([...])`, or build it with `model.add(...)`, starting with `keras.Input(shape=...)`. Use it for a plain stack of layers in which every layer has exactly one input tensor and one output tensor.

## Example

```python
import keras
from keras import layers

model = keras.Sequential(
    [
        keras.Input(shape=(4,)),
        layers.Dense(2, activation="relu", name="layer1"),
        layers.Dense(3, activation="relu", name="layer2"),
        layers.Dense(4, name="layer3"),
    ],
    name="my_sequential",
)
model.summary()
model.pop()               # remove the last layer
print(len(model.layers))
```

## When not to use it

A Sequential model is not appropriate when:
- the model or any layer has multiple inputs or multiple outputs
- you need layer sharing
- you want non-linear topology, such as a residual connection or a multi-branch model

## Input shapes and weights

- Layers create their weights the first time they are called on an input, because the weight shapes depend on the input shape. `layers.Dense(3).weights` is empty at first.
- Starting with `keras.Input(shape=...)` gives the model weights and a defined output shape before seeing any data, and lets `summary()` show the current output shape while you add layers.
- The `Input` object is not part of `model.layers`, since it isn't a layer.
- Specifying the input shape in advance is a recommended best practice when you know it.

## Other uses

- A Sequential model behaves very much like a list of layers: `model.layers`, `add()` and `pop()`.
- Once built, it behaves like a Functional API model, so every layer has `input` and `output` attributes for feature extraction.
- For transfer learning, set `layer.trainable = False` on every layer except the last, or stack a frozen pre-trained base model with new classification layers.

## See also

- [hf-transformers-pipeline](https://iinventedlight.com/library/notes/hf-transformers-pipeline/)
- [python-dataclasses](https://iinventedlight.com/library/notes/python-dataclasses/)

## Claims

- id: C1
  claim: Sequential suits a plain stack of single-input, single-output layers.
  source: S2
  evidence: "appropriate for **a plain stack of layers**"

- id: C2
  claim: The Input object is not shown in model.layers.
  source: S2
  evidence: "the `Input` object is not displayed as part of `model.layers`"

- id: C3
  claim: Specifying input shape in advance is a recommended best practice.
  source: S1
  evidence: "it's a recommended best practice to always specify the input shape"

## Sources

- [S1] The Sequential model. Keras guides. https://keras.io/guides/sequential_model/ . License: Apache-2.0. Accessed 2026-11-18.

- [S2] guides/sequential_model.py (source page). keras-team/keras-io (GitHub). https://github.com/keras-team/keras-io/blob/master/guides/sequential_model.py . License: Apache-2.0. Accessed 2026-11-18.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Keras guides, The Sequential model; keras-team/keras-io (GitHub), guides/sequential_model.py (source page). Apache-2.0 (https://raw.githubusercontent.com/keras-team/keras-io/master/LICENSE). Copyright Keras authors. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
