keras-team/keras · error · ValueError

Cannot deserialize the model (invalid config data?)

Error message

Cannot deserialize the model (invalid config data?)

What it means

Raised while deserializing a legacy (list-form) node record in a Functional config: each inbound-tensor entry must be a 3- or 4-element list [layer_name, node_index, tensor_index, (kwargs)]. An entry with a different length means the config data is malformed or from an incompatible serialization version.

Solutions

  1. Regenerate the model config (e.g. model.to_json() / save + reload) from a working model instead of editing it by hand
  2. Verify the file was produced by a compatible Keras version; re-save after migrating
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

def deserialize_node(node_data, created_layers):
    """Return (args, kwargs) for calling the node layer."""
    if not node_data:
        return [], {}

    if isinstance(node_data, list):
        # Legacy case.
        input_tensors = []
        for input_data in node_data:
            inbound_layer_name = input_data[0]
            inbound_node_index = input_data[1]
            inbound_tensor_index = input_data[2]
            if len(input_data) == 3:
                kwargs = {}
            elif len(input_data) == 4:
                kwargs = input_data[3]
            else:
                raise ValueError(
                    "Cannot deserialize the model (invalid config data?)"
                )

            if inbound_layer_name not in created_layers:
                raise ValueError(
                    "Invalid Functional model configuration. Missing node: "
                    f"{inbound_layer_name}"
                )
            inbound_layer = created_layers[inbound_layer_name]

            # Raise an error if the corresponding layer node
            # has not yet been created
            if len(inbound_layer._inbound_nodes) <= inbound_node_index:
                raise IndexError(
                    "Layer node index out of bounds.\n"
                    f"inbound_layer = {inbound_layer}\n"
                    "inbound_layer._inbound_nodes = "
                    f"{inbound_layer._inbound_nodes}\n"

View on GitHub (pinned to 7a34a03db6)