keras-team/keras · error · ValueError
`cdist` inputs must have rank >= 2
Error message
`cdist` inputs must have rank >= 2
What it means
Error "`cdist` inputs must have rank >= 2" thrown in keras-team/keras.
Source
Thrown at keras/src/backend/numpy/ops/math.py:114
return np.any(mask, axis=-1)
def logsumexp(x, axis=None, keepdims=False):
x = convert_to_tensor(x)
dtype = dtypes.result_type(x.dtype, float)
return scipy.special.logsumexp(x, axis=axis, keepdims=keepdims).astype(
dtype
)
def cdist(x, y):
x = np.asarray(x)
y = np.asarray(y)
dtype = dtypes.result_type(x.dtype, y.dtype, float)
x = x.astype(dtype)
y = y.astype(dtype)
if x.ndim < 2 or y.ndim < 2:
raise ValueError("`cdist` inputs must have rank >= 2")
if x.shape[-1] != y.shape[-1]:
raise ValueError("Last dimension of inputs to `cdist` must match")
diff = x[..., :, None, :] - y[..., None, :, :]
return np.sqrt(np.sum(diff * diff, axis=-1))
def extract_sequences(x, sequence_length, sequence_stride):
*batch_shape, _ = x.shape
batch_shape = list(batch_shape)
shape = x.shape[:-1] + (
(x.shape[-1] - (sequence_length - sequence_stride)) // sequence_stride,
sequence_length,
)
strides = x.strides[:-1] + (
sequence_stride * x.strides[-1],
x.strides[-1],
)
x = np.lib.stride_tricks.as_strided(x, shape=shape, strides=strides)View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/backend/numpy/ops/math.py:114 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/4717148da484c758.
Report an issue: GitHub.