{"record":{"id":"6417aae3b2b163d0","repo":"keras-team/keras","slug":"shape-was-passed-both-positionally-and-as-a-keyw","errorCode":null,"errorMessage":"`shape` was passed both positionally and as a keyword argument.","messagePattern":"`shape` was passed both positionally and as a keyword argument\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/layer.py","lineNumber":591,"sourceCode":"        self._check_super_called()\n        if args:\n            # `args` is only kept to detect the legacy Keras 2 call style\n            # (`add_weight(shape, initializer, dtype, ...)`) and raise a clear\n            # error for positional `name`.\n            if len(args) > 3:\n                raise TypeError(\n                    \"add_weight() takes at most 3 positional arguments \"\n                    f\"but {len(args)} were given.\"\n                )\n            shape_arg = args[0]\n            if isinstance(shape_arg, str):\n                raise ValueError(\n                    \"`name` must be passed as a keyword argument. \"\n                    f\"Received: add_weight('{shape_arg}', ...). \"\n                    f\"Use: add_weight(shape=..., name='{shape_arg}').\"\n                )\n            if shape is not None:\n                raise ValueError(\n                    \"`shape` was passed both positionally and as \"\n                    \"a keyword argument.\"\n                )\n            shape = shape_arg\n            if len(args) > 1:\n                if initializer is not None:\n                    raise ValueError(\n                        \"`initializer` was passed both positionally and \"\n                        \"as a keyword argument.\"\n                    )\n                initializer = args[1]\n            if len(args) > 2:\n                if dtype is not None:\n                    raise ValueError(\n                        \"`dtype` was passed both positionally and as a \"\n                        \"keyword argument.\"\n                    )\n                dtype = args[2]","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/layer.py#L573-L609","documentation":"Error \"`shape` was passed both positionally and as a keyword argument.\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/layers/layer.py:591 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"}