{"record":{"id":"7c9fb52aaf0d423a","repo":"keras-team/keras","slug":"expected-input-to-have-rank-2-received-input-w-7c9fb5","errorCode":null,"errorMessage":"Expected input to have rank >= 2. Received input with shape {x.shape}.","messagePattern":"Expected input to have rank >= 2\\. Received input with shape (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/numpy/linalg.py","lineNumber":104,"sourceCode":"        b = np.expand_dims(b, axis=-1)\n        return _vectorized_solve_triangular(a, b).squeeze(axis=-1)\n    return _vectorized_solve_triangular(a, b)\n\n\ndef svd(x, full_matrices=True, compute_uv=True):\n    return np.linalg.svd(x, full_matrices=full_matrices, compute_uv=compute_uv)\n\n\ndef lstsq(a, b, rcond=None):\n    a = convert_to_tensor(a)\n    b = convert_to_tensor(b)\n    return np.linalg.lstsq(a, b, rcond=rcond)[0]\n\n\ndef matrix_rank(x, tol=None):\n    x = convert_to_tensor(x)\n    if x.ndim < 2:\n        raise ValueError(\n            \"Expected input to have rank >= 2. \"\n            f\"Received input with shape {x.shape}.\"\n        )\n    return np.linalg.matrix_rank(x, tol=tol).astype(\"int32\")\n\n\ndef matrix_power(a, n):\n    a = convert_to_tensor(a)\n    return np.linalg.matrix_power(a, n)\n\n\ndef pinv(x, rcond=None):\n    x = convert_to_tensor(x)\n    return np.linalg.pinv(x, rcond=rcond)\n\n\ndef jvp(fun, primals, tangents, has_aux=False):\n    raise NotImplementedError(\"JVP is not supported by the Numpy backend.\")","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/numpy/linalg.py#L86-L122","documentation":"Error \"Expected input to have rank >= 2. Received input with shape {x.shape}.\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/numpy/linalg.py:104 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}