1. x.grad_fn和x.requires_grad为x的属性
2. x.grad_fn:积分方法名,默认为None
3. x.requires_grad:是否积分的属性,默认为False
4. x.requires_grad_():设置积分的方法,设置之后requires_grad为True
x = torch.Tensor([1, 2, 3])
print(x.grad_fn) # None x的积分方法
print(x.requires_grad) # False 属于x的属性 是否要积分
x.requires_grad_() # 方法:为x赋值requires_grad为True
x = x + 1
print(x.grad_fn) # <AddBackward0 object at 0x0000000002937EB8>
print(x.requires_grad) # True
new_x = x.detach()
print(new_x.grad_fn) # None
print(new_x.requires_grad) # False detach()解绑 返回相同张量的值