tensor梯度的相关性 若一个节点requires_grad被设置为True,那么所有依赖它的节点的requires_grad都为True。 0 import torch 1 x=torch.ones(1) 2 w=torch.ones(1,requires_grad=True) 3 y=x*w 4 x.requires_grad,w.requires_grad,y.requires_grad 5 output: 6 (False, True, True) wx+b的梯度