torch.Tensor.requires_grad_
- Tensor.requires_grad_(requires_grad=True) → Tensor
Change if autograd should record operations on this tensor: sets this tensor’s
requires_gradattribute in-place. Returns this tensor.’s main use case is to tell autograd to begin recording operations on a Tensor . If has (because it was obtained through a DataLoader, or required preprocessing or initialization), makes it so that autograd will begin to record operations on .