def sgd(params,lr,batch_size):
with torch.no_grad():
for param in params:
param -= lr * param.grad / batch_size
param.grad.zero_()
为什么跟老师写的一样的代码,却报错了呢TypeError: unsupported operand type(s) for *: ‘float’ and ‘NoneType’