Here are two cases use “=” and “clone”:
x1 = torch.randn(4)
y1 = x1
z1 = y1.mean().backward()
x2 = torch.randn(4)
y2 = x2.clone()
Since x1 and x2 can get their grads (which are equal), and my questions are:
- what’s the difference in the two cases?
- which one is preferred when creating a computation graph?