Replies: 1 comment
-
I figured out the issue. Please ignore my posting. The issue was in the __init function in the Model definition. Thanks |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to execute the LinearRegressionModel and am getting an empty list for the parameters.
Here is my code
Create a Linear Regression Class
class LinearRegressionModel(nn.Module):
def __init__self():
super().init()
self.weights = nn.Parameter(torch.randn(1,dtype=torch.float),
requires_grad=True)
self.bias = nn.Parameter(torch.randn(1,
dtype=torch.float),
requires_grad=True)
def forward(self,x:torch.Tensor) -> torch.Tensor:
return self.weights * x + self.bias
torch.manual_seed(42)
model_0 = LinearRegressionModel()
list(model_0.parameters())
model_0.parameters()
Beta Was this translation helpful? Give feedback.
All reactions