keras-team/keras · error · ValueError

Sequential model '{self.name}' has already been configured t

Error message

Sequential model '{self.name}' has already been configured to use input shape {self._layers[0].batch_shape}. You cannot add a different Input layer to it.

What it means

Error "Sequential model '{self.name}' has already been configured to use input shape {self._layers[0].batch_shape}. You cannot add a different Input layer to it." thrown in keras-team/keras.

Source

Thrown at keras/src/models/sequential.py:114

        if not isinstance(layer, Layer):
            raise ValueError(
                "Only instances of `keras.Layer` can be "
                f"added to a Sequential model. Received: {layer} "
                f"(of type {type(layer)})"
            )
        if not self._is_layer_name_unique(layer):
            raise ValueError(
                "All layers added to a Sequential model "
                f"should have unique names. Name '{layer.name}' is already "
                "the name of a layer in this model. Update the `name` argument "
                "to pass a unique name."
            )
        if (
            isinstance(layer, InputLayer)
            and self._layers
            and isinstance(self._layers[0], InputLayer)
        ):
            raise ValueError(
                f"Sequential model '{self.name}' has already been configured "
                f"to use input shape {self._layers[0].batch_shape}. You cannot "
                f"add a different Input layer to it."
            )

        self._layers.append(layer)
        if rebuild:
            self._maybe_rebuild()
        else:
            self.built = False
            self._functional = None

    def pop(self, rebuild=True):
        """Removes the last layer in the model.

        Args:
            rebuild: `bool`. Whether to rebuild the model after removing
            the layer. Defaults to `True`.

View on GitHub (pinned to 7a34a03db6)

When it happens

Trigger: Thrown at keras/src/models/sequential.py:114 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25). Data as JSON: /api/errors/5f1c6d9c399da673. Report an issue: GitHub.