keras-team/keras · error · ValueError
Expected input to have rank >= 2. Received input with shape
Error message
Expected input to have rank >= 2. Received input with shape {x.shape}. What it means
Error "Expected input to have rank >= 2. Received input with shape {x.shape}." thrown in keras-team/keras.
Source
Thrown at keras/src/backend/numpy/ops/linalg.py:104
b = np.expand_dims(b, axis=-1)
return _vectorized_solve_triangular(a, b).squeeze(axis=-1)
return _vectorized_solve_triangular(a, b)
def svd(x, full_matrices=True, compute_uv=True):
return np.linalg.svd(x, full_matrices=full_matrices, compute_uv=compute_uv)
def lstsq(a, b, rcond=None):
a = convert_to_tensor(a)
b = convert_to_tensor(b)
return np.linalg.lstsq(a, b, rcond=rcond)[0]
def matrix_rank(x, tol=None):
x = convert_to_tensor(x)
if x.ndim < 2:
raise ValueError(
"Expected input to have rank >= 2. "
f"Received input with shape {x.shape}."
)
return np.linalg.matrix_rank(x, tol=tol).astype("int32")
def matrix_power(a, n):
a = convert_to_tensor(a)
return np.linalg.matrix_power(a, n)
def pinv(x, rcond=None):
x = convert_to_tensor(x)
return np.linalg.pinv(x, rcond=rcond)
def jvp(fun, primals, tangents, has_aux=False):
raise NotImplementedError("JVP is not supported by the Numpy backend.")View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/backend/numpy/ops/linalg.py:104 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/f4891d320e9ca177.
Report an issue: GitHub.