{"record":{"id":"94fd75a46fd323cd","repo":"keras-team/keras","slug":"the-shape-attribute-of-kerastensor-is-immutable","errorCode":null,"errorMessage":"The `shape` attribute of KerasTensor is immutable. One should create a new instance of KerasTensor for this.","messagePattern":"The `shape` attribute of KerasTensor is immutable\\. One should create a new instance of KerasTensor for this\\.","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/common/keras_tensor.py","lineNumber":75,"sourceCode":"            )\n        self._ragged_rank = (\n            int(ragged_rank) if ragged_rank is not None else None\n        )\n        self._row_splits_dtype = (\n            backend.standardize_dtype(row_splits_dtype)\n            if row_splits_dtype is not None\n            else None\n        )\n        self.name = name or auto_name(self.__class__.__name__)\n        self.record_history = record_history\n\n    @property\n    def shape(self):\n        return self._shape\n\n    @shape.setter\n    def shape(self, value):\n        raise AttributeError(\n            \"The `shape` attribute of KerasTensor is immutable. One should \"\n            \"create a new instance of KerasTensor for this.\"\n        )\n\n    @property\n    def dtype(self):\n        return self._dtype\n\n    @dtype.setter\n    def dtype(self, value):\n        raise AttributeError(\n            \"The `dtype` attribute of KerasTensor is immutable. One should \"\n            \"create a new instance of KerasTensor for this.\"\n        )\n\n    @property\n    def sparse(self):\n        return self._sparse","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/common/keras_tensor.py#L57-L93","documentation":"Error \"The `shape` attribute of KerasTensor is immutable. One should create a new instance of KerasTensor for this.\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/common/keras_tensor.py:75 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"}