{"record":{"id":"14b263c90368ceac","repo":"keras-team/keras","slug":"bias-dimension-char-was-requested-but-is-not","errorCode":null,"errorMessage":"Bias dimension '{char}' was requested, but is not part of the output spec '{output_spec}'","messagePattern":"Bias dimension '(.+?)' was requested, but is not part of the output spec '(.+?)'","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/core/einsum_dense.py","lineNumber":1878,"sourceCode":"            input_axes.append(i)\n        else:\n            raise ValueError(\n                f\"Weight dimension '{dim}' did not have a match in either \"\n                f\"the input spec '{input_spec}' or the output \"\n                f\"spec '{output_spec}'. For this layer, the weight must \"\n                \"be fully specified.\"\n            )\n\n    if bias_axes is not None:\n        num_left_elided = elided if left_elided else 0\n        idx_map = {\n            char: output_shape[i + num_left_elided]\n            for i, char in enumerate(output_spec)\n        }\n\n        for char in bias_axes:\n            if char not in output_spec:\n                raise ValueError(\n                    f\"Bias dimension '{char}' was requested, but is not part \"\n                    f\"of the output spec '{output_spec}'\"\n                )\n\n        first_bias_location = min(\n            [output_spec.find(char) for char in bias_axes]\n        )\n        bias_output_spec = output_spec[first_bias_location:]\n\n        bias_shape = [\n            idx_map[char] if char in bias_axes else 1\n            for char in bias_output_spec\n        ]\n\n        if not left_elided:\n            for _ in range(elided):\n                bias_shape.append(1)\n    else:","sourceCodeStart":1860,"sourceCodeEnd":1896,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/core/einsum_dense.py#L1860-L1896","documentation":"EinsumDense's bias_axes argument names output dimensions that should receive a bias. Each letter in bias_axes must be part of the output spec of the equation; otherwise the bias vector's shape is undefined and _analyze_split_string raises this error.","triggerScenarios":"Passing bias_axes containing a letter not in the equation's output, e.g. EinsumDense('ab,bc->ac', ..., bias_axes='b'), or bias_axes with a letter that exists only in the input/weight operands.","commonSituations":"Copy-pasting a Dense-style bias_axes='b' default into a custom equation where 'b' is not an output letter; renaming equation letters without updating bias_axes; assuming bias_axes refers to input dims.","solutions":["Set bias_axes to letters present in the output spec only (commonly the last output letter, e.g. 'c' in 'ab,bc->ac')","Use bias_axes=None to disable bias","Update bias_axes whenever you rename equation letters"],"exampleFix":"# before\nlayer = EinsumDense('ab,bc->ac', output_shape=(None, 5), bias_axes='b')\n# after\nlayer = EinsumDense('ab,bc->ac', output_shape=(None, 5), bias_axes='c')","handlingStrategy":"validation","validationCode":"def bias_axes_valid(eq, bias_axes):\n    out = eq.split('->')[1]\n    return bias_axes is None or all(c in out for c in bias_axes)","typeGuard":"def is_valid_bias_axes(eq, bias_axes):\n    return bias_axes is None or (isinstance(bias_axes, str) and bias_axes_valid(eq, bias_axes))","tryCatchPattern":null,"preventionTips":["Pick bias_axes letters only from the equation's output spec","Default to the last output letter (e.g. 'c' in 'ab,bc->ac')"],"tags":["keras","einsum-dense","bias-axes","einsum-equation"],"backgroundTag":"einsum-equation-syntax","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}