keras-team/keras · error · AttributeError
The `ragged_rank` attribute of KerasTensor is immutable…
Error message
The `ragged_rank` attribute of KerasTensor is immutable. One should create a new instance of KerasTensor for this.
What it means
Raised by the ragged_rank property setter of KerasTensor when code assigns to .ragged_rank. The ragged rank of a symbolic KerasTensor is decided when the tensor is created and cannot be changed in place; this setter exists only to reject such mutation.
Solutions
- Build a new KerasTensor with the required ragged_rank
- Route the tensor through an op or layer that outputs a tensor with the intended ragged structure
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at keras/src/backend/common/keras_tensor.py:108 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/e2a0eff77595ead8.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/backend/common/keras_tensor.py:108
@property
def sparse(self):
return self._sparse
@sparse.setter
def sparse(self, value):
raise AttributeError(
"The `sparse` attribute of KerasTensor is immutable. One should "
"create a new instance of KerasTensor for this."
)
@property
def ragged_rank(self):
return self._ragged_rank
@ragged_rank.setter
def ragged_rank(self, value):
raise AttributeError(
"The `ragged_rank` attribute of KerasTensor is immutable. One "
"should create a new instance of KerasTensor for this."
)
@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._raggedView on GitHub (pinned to 7a34a03db6)