February 24, 2022
How to copy PyTorch Tensor using clone, detach, and deepcopy?
Pragatiwe want to make a copy of a tensor and ensure that any operations are done with the cloned tensor to ensure that the gradients are propagated to the original tensor, we must use clone(). We should use detach() when we don’t want to include a tensor in the resulting computational graph.