keras-team/keras · error · ValueError
Input array must have at least 2 dimensions. Received…
Error message
Input array must have at least 2 dimensions. Received: array.ndim={array.ndim} What it means
The entry guard of `keras.ops.rot90` in the NumPy backend: rotation by 90 degrees is only defined in a plane, which requires an array with at least two dimensions. If `array.ndim < 2` (a scalar or 1D vector), there is no plane to rotate in and the function refuses the input, reporting the actual ndim received.
Solutions
- Pass at least a 2D array (e.g. reshape the vector to (1, n) if a degenerate plane is acceptable)
- Check that upstream slicing did not reduce a matrix to a single row/column vector before calling rot90
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at keras/src/backend/numpy/numpy.py:16 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/3e1e7df2bfa90829.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/backend/numpy/numpy.py:16
import numpy as np
from keras.src import backend
from keras.src import tree
from keras.src.backend import config
from keras.src.backend import standardize_dtype
from keras.src.backend.common import dtypes
from keras.src.backend.common.backend_utils import canonicalize_axis
from keras.src.backend.common.backend_utils import standardize_axis_for_numpy
from keras.src.backend.numpy.core import convert_to_tensor
def rot90(array, k=1, axes=(0, 1)):
"""Rotate an array by 90 degrees in the specified plane."""
if array.ndim < 2:
raise ValueError(
"Input array must have at least 2 dimensions. "
f"Received: array.ndim={array.ndim}"
)
if len(axes) != 2 or axes[0] == axes[1]:
raise ValueError(
f"Invalid axes: {axes}. Axes must be a tuple "
"of two different dimensions."
)
return np.rot90(array, k=k, axes=axes)
def add(x1, x2):
if not isinstance(x1, (int, float)):
x1 = convert_to_tensor(x1)
if not isinstance(x2, (int, float)):
x2 = convert_to_tensor(x2)
dtype = dtypes.result_type(
getattr(x1, "dtype", type(x1)),View on GitHub (pinned to 7a34a03db6)