{"record":{"id":"2afe93207acf183c","repo":"keras-team/keras","slug":"layer-layer-name-expects-len-input-spec-inp","errorCode":null,"errorMessage":"Layer \"{layer_name}\" expects {len(input_spec)} input(s), but it received {len(inputs)} input tensors. Inputs received: {inputs}","messagePattern":"Layer \"(.+?)\" expects (.+?) input\\(s\\), but it received (.+?) input tensors\\. Inputs received: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/input_spec.py","lineNumber":172,"sourceCode":"                        f\"Expected the following keys: {names}\"\n                    )\n                list_inputs.append(inputs[name])\n            inputs = list_inputs\n\n    inputs = tree.flatten(inputs)\n    if len(inputs) != len(input_spec):\n        # Provide appropriate error message for dict inputs.\n        spec_names = [spec.name for spec in input_spec if spec is not None]\n        if len(spec_names) == len(input_spec) and all(spec_names):\n            raise ValueError(\n                f'Layer \"{layer_name}\" expects {len(input_spec)} named '\n                f\"input(s) with keys {spec_names}, but it received \"\n                f\"{len(inputs)} input tensors. Pass inputs as a dict, e.g. \"\n                \"`layer({\"\n                + \", \".join(f\"'{n}': ...\" for n in spec_names)\n                + \"})`.\"\n            )\n        raise ValueError(\n            f'Layer \"{layer_name}\" expects {len(input_spec)} input(s),'\n            f\" but it received {len(inputs)} input tensors. \"\n            f\"Inputs received: {inputs}\"\n        )\n    for input_index, (x, spec) in enumerate(zip(inputs, input_spec)):\n        if spec is None:\n            continue\n        if x is None and spec.optional:\n            continue\n\n        # Having a shape/dtype is the only commonality of the various\n        # tensor-like objects that may be passed. The most common kind of\n        # invalid type we are guarding for is a Layer instance (Functional API),\n        # which does not have a `shape` attribute.\n        if not hasattr(x, \"shape\"):\n            raise ValueError(\n                f\"Inputs to a layer should be tensors. Got '{x}' \"\n                f\"(of type {type(x)}) as input for layer '{layer_name}'.\"","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/input_spec.py#L154-L190","documentation":"Error \"Layer \"{layer_name}\" expects {len(input_spec)} input(s), but it received {len(inputs)} input tensors. Inputs received: {inputs}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/layers/input_spec.py:172 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"}