Solution:
Use tensor. Detach(). Numpy() when turning numpy:
a = torch.ones(5)
b = a.detach().numpy()
print(b)
Problem analysis
When the tensor conversion in calculation, because it has gradient value, it cannot be directly converted to numpy format, so it is better to call . Detach(). Numpy() no matter how