{"record":{"id":"8d92642918bd5587","repo":"keras-team/keras","slug":"all-axis-values-must-be-in-the-range-ndim-ndi","errorCode":null,"errorMessage":"All `axis` values must be in the range [-ndim, ndim). Received inputs with ndim={ndim}, while axis={axis}","messagePattern":"All `axis` values must be in the range \\[-ndim, ndim\\)\\. Received inputs with ndim=(.+?), while axis=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/tensorflow/linalg.py","lineNumber":62,"sourceCode":"\ndef lu_factor(a):\n    lu, p = tf.linalg.lu(a)\n    return lu, tf.math.invert_permutation(p)\n\n\ndef norm(x, ord=None, axis=None, keepdims=False):\n    from keras.src.backend.tensorflow.numpy import moveaxis\n\n    x = convert_to_tensor(x)\n    x_shape = x.shape\n    ndim = x_shape.rank\n\n    if axis is None:\n        axis = tuple(range(ndim))\n    elif isinstance(axis, int):\n        axis = (axis,)\n    if any(a < -ndim or a >= ndim for a in axis):\n        raise ValueError(\n            \"All `axis` values must be in the range [-ndim, ndim). \"\n            f\"Received inputs with ndim={ndim}, while axis={axis}\"\n        )\n    axis = axis[0] if len(axis) == 1 else axis\n    num_axes = 1 if isinstance(axis, int) else len(axis)\n\n    if standardize_dtype(x.dtype) == \"int64\":\n        dtype = config.floatx()\n    else:\n        dtype = dtypes.result_type(x.dtype, float)\n    x = cast(x, dtype)\n\n    # Ref: jax.numpy.linalg.norm\n    if num_axes == 1:\n        if ord is None or ord == 2:\n            return tf.sqrt(\n                tf.reduce_sum(x * tf.math.conj(x), axis=axis, keepdims=keepdims)\n            )","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/tensorflow/linalg.py#L44-L80","documentation":"Error \"All `axis` values must be in the range [-ndim, ndim). Received inputs with ndim={ndim}, while axis={axis}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/tensorflow/linalg.py:62 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"}