keras-team/keras · error · ValueError

All `outputs` values must be KerasTensors. Received…

Error message

All `outputs` values must be KerasTensors. Received: outputs={outputs} including invalid value {x} of type {type(x)}

What it means

Constructor guard on Functional: every leaf of the outputs structure must be a KerasTensor. Outputs are expected to be symbolic tensors derived from the input placeholders through layers; raw tensors or Python values that are not KerasTensors abort model construction.

Solutions

  1. Build outputs by calling layers on your Input placeholders, then pass those symbolic tensors
  2. Check for accidental Python values (None, numpy arrays) in the outputs structure
  3. Wrap non-Keras intermediate values in an appropriate layer instead of converting them manually
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at keras/src/models/functional.py:126 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/a1a45abf08273bd7. Report an issue: GitHub.

Appendix: source

Thrown at keras/src/models/functional.py:126

                        "dict must match the names of the corresponding "
                        f"tensors. Received key '{k}' mapping to value {v} "
                        f"which has name '{v.name}'. Change the tensor name to "
                        f"'{k}' (via `Input(..., name='{k}')`)"
                    )

        trainable = kwargs.pop("trainable", None)
        flat_inputs = tree.flatten(inputs)
        flat_outputs = tree.flatten(outputs)
        for x in flat_inputs:
            if not isinstance(x, backend.KerasTensor):
                raise ValueError(
                    "All `inputs` values must be KerasTensors. Received: "
                    f"inputs={inputs} including invalid value {x} of "
                    f"type {type(x)}"
                )
        for x in flat_outputs:
            if not isinstance(x, backend.KerasTensor):
                raise ValueError(
                    "All `outputs` values must be KerasTensors. Received: "
                    f"outputs={outputs} including invalid value {x} of "
                    f"type {type(x)}"
                )

        if not all(is_input_keras_tensor(t) for t in flat_inputs):
            inputs, outputs = clone_graph_nodes(inputs, outputs)

        with tracking.DotNotTrackScope():
            Function.__init__(self, inputs, outputs, name=name)

        if trainable is not None:
            self.trainable = trainable

        for layer in self.layers:
            self._tracker.track(layer)
        self.build(None)
        # We will convert directly (to the correct dtype per input).

View on GitHub (pinned to 7a34a03db6)