keras-team/keras · error · AttributeError
Sequential model '{self.name}' has no defined inputs yet.
Error message
Sequential model '{self.name}' has no defined inputs yet. What it means
The inputs property returns the input KerasTensors of the functional graph; without build or an InputLayer there are none, so access fails.
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)
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 '{self.name}' has no defined input shape ye
- Sequential model '{self.name}' has no defined output shape y
- Sequential model '{self.name}' has no defined outputs yet.
- You must build the layer before accessing `kernel`.
- Cannot enable lora on a layer that isn't yet built.
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/80a425a7447cfcb6.
Report an issue: GitHub.