keras-team/keras · error · AttributeError
The `shape` attribute of KerasTensor is immutable. One shoul
Error message
The `shape` attribute of KerasTensor is immutable. One should create a new instance of KerasTensor for this.
What it means
Error "The `shape` attribute of KerasTensor is immutable. One should create a new instance of KerasTensor for this." thrown in keras-team/keras.
Source
Thrown at keras/src/backend/common/keras_tensor.py:75
)
self._ragged_rank = (
int(ragged_rank) if ragged_rank is not None else None
)
self._row_splits_dtype = (
backend.standardize_dtype(row_splits_dtype)
if row_splits_dtype is not None
else None
)
self.name = name or auto_name(self.__class__.__name__)
self.record_history = record_history
@property
def shape(self):
return self._shape
@shape.setter
def shape(self, value):
raise AttributeError(
"The `shape` attribute of KerasTensor is immutable. One should "
"create a new instance of KerasTensor for this."
)
@property
def dtype(self):
return self._dtype
@dtype.setter
def dtype(self, value):
raise AttributeError(
"The `dtype` attribute of KerasTensor is immutable. One should "
"create a new instance of KerasTensor for this."
)
@property
def sparse(self):
return self._sparseView on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/backend/common/keras_tensor.py:75 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/94fd75a46fd323cd.
Report an issue: GitHub.