keras-team/keras · error · ValueError
All `axis` values must be in the range [-ndim, ndim). Receiv
Error message
All `axis` values must be in the range [-ndim, ndim). Received inputs with ndim={ndim}, while axis={axis} What it means
Error "All `axis` values must be in the range [-ndim, ndim). Received inputs with ndim={ndim}, while axis={axis}" thrown in keras-team/keras.
Source
Thrown at keras/src/backend/tensorflow/linalg.py:62
def lu_factor(a):
lu, p = tf.linalg.lu(a)
return lu, tf.math.invert_permutation(p)
def norm(x, ord=None, axis=None, keepdims=False):
from keras.src.backend.tensorflow.numpy import moveaxis
x = convert_to_tensor(x)
x_shape = x.shape
ndim = x_shape.rank
if axis is None:
axis = tuple(range(ndim))
elif isinstance(axis, int):
axis = (axis,)
if any(a < -ndim or a >= ndim for a in axis):
raise ValueError(
"All `axis` values must be in the range [-ndim, ndim). "
f"Received inputs with ndim={ndim}, while axis={axis}"
)
axis = axis[0] if len(axis) == 1 else axis
num_axes = 1 if isinstance(axis, int) else len(axis)
if standardize_dtype(x.dtype) == "int64":
dtype = config.floatx()
else:
dtype = dtypes.result_type(x.dtype, float)
x = cast(x, dtype)
# Ref: jax.numpy.linalg.norm
if num_axes == 1:
if ord is None or ord == 2:
return tf.sqrt(
tf.reduce_sum(x * tf.math.conj(x), axis=axis, keepdims=keepdims)
)View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/backend/tensorflow/linalg.py:62 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/8d92642918bd5587.
Report an issue: GitHub.