ML Community Day is November 9! Join us for updates from TensorFlow, JAX, and more Learn more


Sequential groups a linear stack of layers into a tf.keras.Model.

Inherits From: Model, Layer, Module

Used in the notebooks

Used in the guide Used in the tutorials

Sequential provides training and inference features on this model.


# Optionally, the first layer can receive an `input_shape` argument:
model = tf.keras.Sequential()
model.add(tf.keras.layers.Dense(8, input_shape=(16,)))
# Afterwards, we do automatic shape inference:
# This is identical to the following:
model = tf.keras.Sequential()
# Note that you can also omit the `input_shape` argument.
# In that case the model doesn't have any weights until the first call
# to a training/evaluation method (since it isn't yet built):
model = tf.keras.Sequential()