-
Hi, Build a PyTorch model by subclassing nn.Module and implement forward() function. Everything works well when I use weights and bias in the class. But when I replace them with nn.Linear(), I get an error. This also happens with the solution provided(option 2 solution). Data:
Data Split:
Class Definition
Error in the below code
Error
Kindly help me with this. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Found the problem. It has to do with the shape of X. After adding the unsqueeze, error got resolved
|
Beta Was this translation helpful? Give feedback.
-
But, please, why do we need to unsqueeze(dim=1) @mrdbourke @Pvry ? |
Beta Was this translation helpful? Give feedback.
Found the problem. It has to do with the shape of X. After adding the unsqueeze, error got resolved