pytorch / 2 / generated / torch.tensor.retain_grad.html

torch.Tensor.retain_grad

Tensor.retain_grad() → None

Enables this Tensor to have their grad populated during backward(). 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