{"record":{"id":"3e1e7df2bfa90829","repo":"keras-team/keras","slug":"input-array-must-have-at-least-2-dimensions-recei-3e1e7d","errorCode":null,"errorMessage":"Input array must have at least 2 dimensions. Received: array.ndim={array.ndim}","messagePattern":"Input array must have at least 2 dimensions\\. Received: array\\.ndim=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/numpy/numpy.py","lineNumber":16,"sourceCode":"import numpy as np\n\nfrom 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)),","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/numpy/numpy.py#L1-L34","documentation":"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.","triggerScenarios":"Thrown at keras/src/backend/numpy/numpy.py:16 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"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"}