{"record":{"id":"e1779ce632d2d3b5","repo":"keras-team/keras","slug":"invalid-axes-axes-axes-must-be-a-tuple-of-two-e1779c","errorCode":null,"errorMessage":"Invalid axes: {axes}. Axes must be a tuple of two different dimensions.","messagePattern":"Invalid axes: (.+?)\\. Axes must be a tuple of two different dimensions\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/numpy/numpy.py","lineNumber":21,"sourceCode":"from keras.src import backend\nfrom keras.src import tree\nfrom keras.src.backend import config\nfrom keras.src.backend import standardize_dtype\nfrom keras.src.backend.common import dtypes\nfrom keras.src.backend.common.backend_utils import canonicalize_axis\nfrom keras.src.backend.common.backend_utils import standardize_axis_for_numpy\nfrom keras.src.backend.numpy.core import convert_to_tensor\n\n\ndef rot90(array, k=1, axes=(0, 1)):\n    \"\"\"Rotate an array by 90 degrees in the specified plane.\"\"\"\n    if array.ndim < 2:\n        raise ValueError(\n            \"Input array must have at least 2 dimensions. \"\n            f\"Received: array.ndim={array.ndim}\"\n        )\n    if len(axes) != 2 or axes[0] == axes[1]:\n        raise ValueError(\n            f\"Invalid axes: {axes}. Axes must be a tuple \"\n            \"of two different dimensions.\"\n        )\n    return np.rot90(array, k=k, axes=axes)\n\n\ndef add(x1, x2):\n    if not isinstance(x1, (int, float)):\n        x1 = convert_to_tensor(x1)\n    if not isinstance(x2, (int, float)):\n        x2 = convert_to_tensor(x2)\n    dtype = dtypes.result_type(\n        getattr(x1, \"dtype\", type(x1)),\n        getattr(x2, \"dtype\", type(x2)),\n    )\n    x1 = convert_to_tensor(x1, dtype)\n    x2 = convert_to_tensor(x2, dtype)\n    return np.add(x1, x2)","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/numpy/numpy.py#L3-L39","documentation":"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.","triggerScenarios":"Thrown at keras/src/backend/numpy/numpy.py:21 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}