我该如何解决这个 torch.zero() 问题?

How could I fix this torch.zero() problem?

我正在尝试自己编写逻辑回归,但在初始化此 torch.zero() 时发现错误。

代码:

w = torch.normal(0, 0.01, size=(2,1), requires_grad=True)
b = torch.zeros(1,require_grad=True) # Error occured here

错误信息:

Traceback (most recent call last):
  File "linearRegression.py", line 37, in <module>
    b = torch.zeros(1,require_grad=True)
TypeError: zeros() received an invalid combination of arguments - got (int, require_grad=bool), but expected one of:
 * (tuple of ints size, *, tuple of names names, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)
 * (tuple of ints size, *, Tensor out, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)

你打错了,把require_grad改成requires_grad