keras-team/keras · error · ValueError
`ragged=True` is not supported with numpy backend
Error message
`ragged=True` is not supported with numpy backend
What it means
`keras.ops.convert_to_tensor` in the NumPy backend raises this when `ragged=True` is requested. Ragged (variable-length) tensors have no NumPy equivalent, so the backend's conversion function rejects the ragged option immediately after its sparse check; it indicates an unsupported input type on this backend rather than malformed data.
Solutions
- Convert ragged inputs to dense (e.g. pad to uniform length with keras.utils.pad_sequences) and pass ragged=False
- Use the TensorFlow backend, which natively supports ragged tensors
- Bucket or truncate variable-length sequences to fixed length before conversion
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at keras/src/backend/numpy/ops/core.py:37 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/fa2d142802e55613.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/backend/numpy/ops/core.py:37
def _initialize(self, value):
self._value = value
def _direct_assign(self, value):
self._value = np.array(value, dtype=self._dtype)
def _convert_to_tensor(self, value, dtype=None):
return convert_to_tensor(value, dtype=dtype)
# Overload native accessor.
def __array__(self):
return self.value
def convert_to_tensor(x, dtype=None, sparse=None, ragged=None):
if sparse:
raise ValueError("`sparse=True` is not supported with numpy backend")
if ragged:
raise ValueError("`ragged=True` is not supported with numpy backend")
if dtype is not None:
dtype = standardize_dtype(dtype)
if isinstance(x, Variable):
if dtype and dtype != x.dtype:
return x.value.astype(dtype)
return x.value
if not is_tensor(x) and standardize_dtype(dtype) == "bfloat16":
# Can't create bfloat16 arrays on the fly (e.g. from a h5 Dataset).
# Instead we convert "as is" (to stored dtype) and cast.
return np.asarray(x).astype(dtype)
if dtype is None:
dtype = result_type(
*[getattr(item, "dtype", type(item)) for item in tree.flatten(x)]
)
return np.array(x, dtype=dtype)
def convert_to_numpy(x):View on GitHub (pinned to 7a34a03db6)