keras-team/keras · error · ValueError
The structure of `inputs` doesn't match the expected…
Error message
The structure of `inputs` doesn't match the expected structure.\nExpected: {model_inputs_struct}\nReceived: inputs={inputs_struct} What it means
Structural guard in Functional.__call__: the inputs passed at call time must match the nesting structure of the model's declared inputs (lists converted to tuples before comparison). This fires when, e.g., a multi-input model built from a dict or list of Inputs is called with a single tensor or a differently nested structure.
Solutions
- Pass inputs with exactly the structure of model.input: a dict with the same keys, or a list/tuple of the same length and nesting
- For a single-input model, pass the tensor directly, not wrapped in a list
- Use model.input_shape / model.input as a reference for the expected structure
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at keras/src/models/functional.py:253 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/282206f3905bd116.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/models/functional.py:253
tree.lists_to_tuples(inputs),
tree.lists_to_tuples(self._inputs_struct),
)
except:
model_inputs_struct = tree.map_structure(
lambda x: "None" if x is None else x.name,
self._inputs_struct,
)
inputs_struct = tree.map_structure(
lambda x: "None" if x is None else f"Tensor(shape={x.shape})",
inputs,
)
msg = (
"The structure of `inputs` doesn't match the expected "
f"structure.\nExpected: {model_inputs_struct}\n"
f"Received: inputs={inputs_struct}"
)
if raise_exception:
raise ValueError(msg)
warnings.warn(msg)
def _convert_inputs_to_tensors(self, flat_inputs):
converted = []
for x, input_tensor in zip(flat_inputs, self._inputs):
if x is None:
# Only enforce optional semantics when the input tensor was
# created by an `InputLayer`. For other kinds of tensors
# (e.g. tensors produced dynamically) preserve previous
# behavior and allow None to pass through.
input_layer = None
if (
hasattr(input_tensor, "_keras_history")
and input_tensor._keras_history
):
input_layer = input_tensor._keras_history.operation
if isinstance(input_layer, InputLayer):View on GitHub (pinned to 7a34a03db6)