keras-team/keras · error · AttributeError
The `ragged` attribute of KerasTensor is immutable. One…
Error message
The `ragged` attribute of KerasTensor is immutable. One should create a new instance of KerasTensor for this.
What it means
Raised by the ragged property setter of KerasTensor when code assigns to .ragged. Whether a KerasTensor is ragged is fixed when it is created as part of the symbolic graph, so the setter exists solely to fail in-place mutation attempts.
Solutions
- Instantiate a new KerasTensor with ragged set as needed
- Obtain the ragged (or non-ragged) tensor from the op/layer that constructs it rather than mutating an existing one
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at keras/src/backend/common/keras_tensor.py:130 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/cb533f772d757f9d.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/backend/common/keras_tensor.py:130
@property
def row_splits_dtype(self):
return self._row_splits_dtype
@row_splits_dtype.setter
def row_splits_dtype(self, value):
raise AttributeError(
"The `row_splits_dtype` attribute of KerasTensor is immutable. One "
"should create a new instance of KerasTensor for this."
)
@property
def ragged(self):
return self._ragged
@ragged.setter
def ragged(self, value):
raise AttributeError(
"The `ragged` attribute of KerasTensor is immutable. One should "
"create a new instance of KerasTensor for this."
)
@property
def ndim(self):
return len(self.shape)
def reshape(self, newshape):
from keras.src import ops
return ops.Reshape(newshape)(self)
def squeeze(self, axis=None):
from keras.src import ops
return ops.Squeeze(axis)(self)
View on GitHub (pinned to 7a34a03db6)