标签: python-3.x
我正在编写如下代码,运行并获得异常:
AttributeError: 'NoneType' object has no attribute 'zero_'
print(w.grad)一无所有
print(w.grad)
w = Variable(torch.randn(1), requires_grad=True) b = Variable(torch.zeros(1), requires_grad=True) w.grad.zero_()