keras-team/keras · error · ValueError

The structure of `inputs` doesn't match the expected structu

Error message

The structure of `inputs` doesn't match the expected structure.\nExpected: {model_inputs_struct}\nReceived: inputs={inputs_struct}

What it means

Error "The structure of `inputs` doesn't match the expected structure.\nExpected: {model_inputs_struct}\nReceived: inputs={inputs_struct}" thrown in keras-team/keras.

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)

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.