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/jax/ops/linalg.py:105

def solve_triangular(a, b, lower=False):
    return jsp.linalg.solve_triangular(a, b, lower=lower)


def svd(x, full_matrices=True, compute_uv=True):
    return jnp.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 jnp.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 jnp.linalg.matrix_rank(x, tol=tol).astype("int32")


def matrix_power(a, n):
    a = convert_to_tensor(a)
    return jnp.linalg.matrix_power(a, n)


def pinv(x, rcond=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}."
        )

View on GitHub (pinned to 7a34a03db6)

When it happens

Trigger: Thrown at keras/src/backend/jax/ops/linalg.py:105 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/2d8ea5571720d68b. Report an issue: GitHub.