{"record":{"id":"824bfd18890a0366","repo":"keras-team/keras","slug":"layer-layer-name-expects-len-input-spec-nam","errorCode":null,"errorMessage":"Layer \"{layer_name}\" expects {len(input_spec)} named input(s) with keys {spec_names}, but it received {len(inputs)} input tensors. Pass inputs as a dict, e.g. `layer({'{n}': ...})`.","messagePattern":"Layer \"(.+?)\" expects (.+?) named input\\(s\\) with keys (.+?), but it received (.+?) input tensors\\. Pass inputs as a dict, e\\.g\\. `layer\\((.+?)': \\.\\.\\.\\}\\)`\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/input_spec.py","lineNumber":164,"sourceCode":"        if all(names):\n            list_inputs = []\n            for name in names:\n                if name not in inputs:\n                    raise ValueError(\n                        f'Missing data for input \"{name}\". '\n                        \"You passed a data dictionary with keys \"\n                        f\"{list(inputs.keys())}. \"\n                        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","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/input_spec.py#L146-L182","documentation":"Error \"Layer \"{layer_name}\" expects {len(input_spec)} named input(s) with keys {spec_names}, but it received {len(inputs)} input tensors. Pass inputs as a dict, e.g. `layer({'{n}': ...})`.\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/layers/input_spec.py:164 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"}