{"record":{"id":"0d4ef65ff13b1cbe","repo":"keras-team/keras","slug":"jvp-is-not-supported-by-the-numpy-backend-0d4ef6","errorCode":null,"errorMessage":"JVP is not supported by the Numpy backend.","messagePattern":"JVP is not supported by the Numpy backend\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/numpy/ops/linalg.py","lineNumber":122,"sourceCode":"        raise ValueError(\n            \"Expected input to have rank >= 2. \"\n            f\"Received input with shape {x.shape}.\"\n        )\n    return np.linalg.matrix_rank(x, tol=tol).astype(\"int32\")\n\n\ndef matrix_power(a, n):\n    a = convert_to_tensor(a)\n    return np.linalg.matrix_power(a, n)\n\n\ndef pinv(x, rcond=None):\n    x = convert_to_tensor(x)\n    return np.linalg.pinv(x, rcond=rcond)\n\n\ndef jvp(fun, primals, tangents, has_aux=False):\n    raise NotImplementedError(\"JVP is not supported by the Numpy backend.\")\n","sourceCodeStart":104,"sourceCodeEnd":123,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/numpy/ops/linalg.py#L104-L123","documentation":"The NumPy backend's `jvp` (Jacobian-vector product) is a stub: automatic differentiation requires a tracing/autodiff framework, and plain NumPy execution has none, so the function unconditionally raises NotImplementedError. This is a backend capability declaration — any jvp call on the NumPy backend fails, regardless of arguments.","triggerScenarios":"Thrown at keras/src/backend/numpy/ops/linalg.py:122 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Switch to the JAX or TensorFlow backend, which support forward-mode autodiff via keras.ops.jvp","Implement the Jacobian-vector product manually by evaluating the function with dual numbers or finite differences on NumPy arrays","Guard code paths that need jvp so they only run when backend() is 'jax' or 'tensorflow'"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}