keras-team/keras · error · ValueError
Invalid axes: . Axes must be a tuple of two different…
Error message
Invalid axes: {axes}. Axes must be a tuple of two different dimensions. What it means
The second guard in `keras.ops.rot90`: after confirming ndim >= 2, it validates the `axes` pair that selects the rotation plane. The axes must be exactly two distinct dimensions of the array; passing fewer/more axes, duplicate axes (a degenerate plane), or out-of-range indices triggers this error naming the offending tuple.
Solutions
- Provide a tuple of two different valid axis indices, e.g. axes=(0, 1) or axes=(1, 2)
- Keep the default axes=(0, 1) when the standard rotation plane is intended
- Validate axis values against array.ndim before calling rot90 when axes come from user input
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at keras/src/backend/numpy/numpy.py:21 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/e1779ce632d2d3b5.
Report an issue: GitHub.
Appendix: source
Thrown at keras/src/backend/numpy/numpy.py:21
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)),
getattr(x2, "dtype", type(x2)),
)
x1 = convert_to_tensor(x1, dtype)
x2 = convert_to_tensor(x2, dtype)
return np.add(x1, x2)View on GitHub (pinned to 7a34a03db6)