'How could I fix this torch.zero() problem?
I'm trying to write a Logistic Regression by myself, but I found an error while initializing this torch.zero().
code:
w = torch.normal(0, 0.01, size=(2,1), requires_grad=True)
b = torch.zeros(1,require_grad=True) # Error occured here
Error message:
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)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
