keras-team/keras · error · IndexError

Layer node index out of bounds. inbound_layer = {layer} inbo

Error message

Layer node index out of bounds.
inbound_layer = {layer}
inbound_layer._inbound_nodes = {layer._inbound_nodes}
inbound_node_index = {inbound_node_index}

What it means

Error "Layer node index out of bounds. inbound_layer = {layer} inbound_layer._inbound_nodes = {layer._inbound_nodes} inbound_node_index = {inbound_node_index}" thrown in keras-team/keras.

Source

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

                inbound_node.output_tensors[inbound_tensor_index]
            )
        return [unpack_singleton(input_tensors)], kwargs

    args = serialization_lib.deserialize_keras_object(node_data["args"])
    kwargs = serialization_lib.deserialize_keras_object(node_data["kwargs"])

    def convert_revived_tensor(x):
        if isinstance(x, backend.KerasTensor):
            history = x._pre_serialization_keras_history
            if history is None:
                return x
            layer = created_layers.get(history[0], None)
            if layer is None:
                raise ValueError(f"Unknown layer: {history[0]}")
            inbound_node_index = history[1]
            inbound_tensor_index = history[2]
            if len(layer._inbound_nodes) <= inbound_node_index:
                raise IndexError(
                    "Layer node index out of bounds.\n"
                    f"inbound_layer = {layer}\n"
                    f"inbound_layer._inbound_nodes = {layer._inbound_nodes}\n"
                    f"inbound_node_index = {inbound_node_index}"
                )
            inbound_node = layer._inbound_nodes[inbound_node_index]
            return inbound_node.output_tensors[inbound_tensor_index]
        return x

    args = tree.map_structure(convert_revived_tensor, args)
    kwargs = tree.map_structure(convert_revived_tensor, kwargs)
    return args, kwargs


def is_input_keras_tensor(x):
    (
        operation,
        node_index,

View on GitHub (pinned to 7a34a03db6)

When it happens

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