← All notes

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

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:

Input shapes and weights

Other uses

See also

Claims

Sources

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.

License: CC-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.

Cite this

Permanent ID: iil:note:1f1ym458

iinventedlight. 2026. "Keras Sequential models stack layers with one input and one output each." iinventedlight Library, iil:note:1f1ym458, version of 2026-11-18. https://iinventedlight.com/library/notes/keras-sequential/. License: CC-BY-4.0.

@misc{iil_note_1f1ym458,
  author = {{iinventedlight}},
  title = {{Keras Sequential models stack layers with one input and one output each}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/keras-sequential/},
  note = {Permanent ID iil:note:1f1ym458. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/keras-sequential.md.