keras-team/keras · error · AttributeError
Sequential model ' ' has no defined inputs yet.
Error message
Sequential model '{self.name}' has no defined inputs yet. What it means
Returned error text when accessing input_shape/inputs-related properties on a Sequential model that has not been built and has no Input layer or input_shape defined, so the input specification is not yet known.
Solutions
- Build the model first
- Construct with an explicit Input layer
- Derive inputs yourself from your data pipeline if the model is unbuilt
Example fix
# before ins = model.inputs # after model.build((None, 28, 28)) ins = model.inputs
Defensive patterns
Strategy: try-catch
Validate before calling
has_inputs = bool(model._functional)
Try / catch
try:
ins = model.inputs
except AttributeError:
model.build(input_shape)
ins = model.inputs Prevention
- Define the input with keras.Input before accessing .inputs
- Build the model before introspection
When it happens
Trigger: model = keras.Sequential(); model.inputs before any build/InputLayer
Common situations: Keras 3 migrations where code assumed graph-mode inputs were always available
Related errors
- Sequential model ' ' has no defined input shape yet.
- Sequential model ' ' has no defined output shape yet.
- Sequential model ' ' has no defined outputs yet.
- A Sequential model configuration must be a dictionary…
- Argument `input_tensors` must contain a single tensor.
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/80a425a7447cfcb6.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/models/sequential.py:318
if self._functional:
return self._functional.input_shape
raise AttributeError(
f"Sequential model '{self.name}' has no defined input shape yet."
)
@property
def output_shape(self):
if self._functional:
return self._functional.output_shape
raise AttributeError(
f"Sequential model '{self.name}' has no defined output shape yet."
)
@property
def inputs(self):
if self._functional:
return self._functional.inputs
raise AttributeError(
f"Sequential model '{self.name}' has no defined inputs yet."
)
@property
def outputs(self):
if self._functional:
return self._functional.outputs
raise AttributeError(
f"Sequential model '{self.name}' has no defined outputs yet."
)
@property
def input_dtype(self):
# Sequential.__call__ will try to convert its inputs
# to the dtype expected by its input layer, if any.
layers = self._layers
if layers and isinstance(layers[0], InputLayer):
return layers[0].dtypeView on GitHub (pinned to 7a34a03db6)