torch.func.grad_and_value
- torch.func.grad_and_value(func, argnums=0, has_aux=False)
Returns a function to compute a tuple of the gradient and primal, or forward, computation.
- Parameters:
() – A Python function that takes one or more arguments. Must return a single-element Tensor. If specified equals , function can return a tuple of single-element Tensor and other auxiliary objects: .