On this page
torch.Tensor.retain_grad
Tensor.retain_grad() → None
-
Enables this Tensor to have their
grad
populated duringbackward()
. This is a no-op for leaf tensors.
© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/2.1/generated/torch.Tensor.retain_grad.html