{"record":{"id":"28ab9876d2b3fbb7","repo":"keras-team/keras","slug":"the-following-variable-path-is-found-twice-in-the","errorCode":null,"errorMessage":"The following variable path is found twice in the model: '{v.path}'. `get_state_tree()` can only be called when all variable paths are unique. Make sure to give unique names to your layers (and other objects).","messagePattern":"The following variable path is found twice in the model: '(.+?)'\\. `get_state_tree\\(\\)` can only be called when all variable paths are unique\\. Make sure to give unique names to your layers \\(and other objects\\)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/models/model.py","lineNumber":1144,"sourceCode":"        variables[\"trainable_variables\"] = self._create_nested_dict(\n            self.trainable_variables, value_format\n        )\n        variables[\"non_trainable_variables\"] = self._create_nested_dict(\n            self.non_trainable_variables, value_format\n        )\n        variables[\"optimizer_variables\"] = self._create_nested_dict(\n            self.optimizer.variables, value_format\n        )\n        variables[\"metrics_variables\"] = self._create_nested_dict(\n            self.metrics_variables, value_format\n        )\n        return variables\n\n    def _create_nested_dict(self, variables, value_format):\n        flat_dict = {}\n        for v in variables:\n            if v.path in flat_dict:\n                raise ValueError(\n                    \"The following variable path is found twice in the model: \"\n                    f\"'{v.path}'. `get_state_tree()` can only be called when \"\n                    \"all variable paths are unique. Make sure to give unique \"\n                    \"names to your layers (and other objects).\"\n                )\n            if value_format == \"backend_tensor\":\n                flat_dict[v.path] = v.value\n            elif value_format == \"numpy_array\":\n                flat_dict[v.path] = v.numpy()\n            else:\n                raise ValueError(\n                    \"Invalid `value_format` argument. Expected one of \"\n                    \"{'numpy_array', 'backend_tensor'}. Received: \"\n                    f\"value_format={value_format}\"\n                )\n\n        nested_dict = {}\n        for path, value in flat_dict.items():","sourceCodeStart":1126,"sourceCodeEnd":1162,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/models/model.py#L1126-L1162","documentation":"Error \"The following variable path is found twice in the model: '{v.path}'. `get_state_tree()` can only be called when all variable paths are unique. Make sure to give unique names to your layers (and other objects).\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/models/model.py:1144 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"}