{"record":{"id":"71944fb18d84fc6c","repo":"keras-team/keras","slug":"input-input-index-with-name-spec-name-of-lay-71944f","errorCode":null,"errorMessage":"Input {input_index} with name '{spec.name}' of layer '{layer_name}' is incompatible with the layer: expected axis {axis} of input shape to have value {value}, but received input with shape {shape}","messagePattern":"Input (.+?) with name '(.+?)' of layer '(.+?)' is incompatible with the layer: expected axis (.+?) of input shape to have value (.+?), but received input with shape (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/input_spec.py","lineNumber":239,"sourceCode":"        # Check dtype.\n        if spec.dtype is not None:\n            dtype = backend.standardize_dtype(x.dtype)\n            if dtype != spec.dtype:\n                raise ValueError(\n                    f\"Input {input_index} with name '{spec.name}' of layer \"\n                    f\"'{layer_name}' is incompatible with the layer: \"\n                    f\"expected dtype={spec.dtype}, \"\n                    f\"found dtype={dtype}\"\n                )\n\n        # Check specific shape axes.\n        if spec.axes:\n            for axis, value in spec.axes.items():\n                if value is not None and shape[axis] not in {\n                    value,\n                    None,\n                }:\n                    raise ValueError(\n                        f\"Input {input_index} with name '{spec.name}' of layer \"\n                        f\"'{layer_name}' is incompatible with the layer: \"\n                        f\"expected axis {axis} of input shape to have value \"\n                        f\"{value}, but received input with shape {shape}\"\n                    )\n        # Check shape.\n        if spec.shape is not None:\n            spec_shape = spec.shape\n            if spec.allow_last_axis_squeeze:\n                if shape and shape[-1] == 1:\n                    shape = shape[:-1]\n                if spec_shape and spec_shape[-1] == 1:\n                    spec_shape = spec_shape[:-1]\n            for spec_dim, dim in zip(spec_shape, shape):\n                if spec_dim is not None and dim is not None:\n                    if spec_dim != dim:\n                        raise ValueError(\n                            f\"Input {input_index} with name '{spec.name}' of \"","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/input_spec.py#L221-L257","documentation":"Error \"Input {input_index} with name '{spec.name}' of layer '{layer_name}' is incompatible with the layer: expected axis {axis} of input shape to have value {value}, but received input with shape {shape}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/layers/input_spec.py:239 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}