Skip to content

Exercise 1: Error while building a PyTorch model by subclassing nn.Module using nn.Linear #196

Answered by yasaswi-p
yasaswi-p asked this question in Q&A
Discussion options

You must be logged in to vote

Found the problem. It has to do with the shape of X. After adding the unsqueeze, error got resolved

weight = 0.3
bias = 0.9
X = torch.arange(0, 1, 0.01).unsqueeze(dim=1)
y = weight * X + bias

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@mrdbourke
Comment options

Answer selected by yasaswi-p
Comment options

You must be logged in to vote
1 reply
@mrdbourke
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants