fn
gradcheck
→bool True if all gradients agree within tolerance.gradcheck(func: Callable[..., Tensor | tuple[Tensor, ...]], inputs: Sequence[Tensor], eps: float = 1e-06, atol: float = 1e-05, rtol: float = 0.001, raise_exception: bool = True)Compare analytical gradients from backward() against finite-difference Jacobians.
Implemented entirely with the Lucid C++ engine — no numpy.
Parameters
funccallableScalar-valued function mapping Tensor inputs to a single-element Tensor.
inputssequence of TensorInputs to func that require grad (must be float tensors).
epsfloat= 1e-06Finite-difference step size (default 1e-6).
atolfloat= 1e-05Tolerances for the gradient comparison.
rtolfloat= 1e-05Tolerances for the gradient comparison.
raise_exceptionbool= TrueRaise AssertionError on mismatch (default True), else return False.