Skip to content

Having an issue with Tensor sizes from model while doing Udemy course #853

Answered by LuluW8071
david-bickford asked this question in Q&A
Discussion options

You must be logged in to vote
class LinearRegressionModel(nn.Module):
  def __init__(self):
    super().__init__()
    self.weights = nn.Parameter(torch.randn(1, requires_grad=True))

    self.bias = nn.Parameter(torch.randn(1, requires_grad=True))

  #forward method to define the computation in the model
  def forward(self, x:torch.Tensor) -> torch.Tensor:
    return self.weights * X + self.bias
return self.weights * X + self.bias

The original X value is being returned from original X data where it should have been x for forwarding the input data at a time as you have wrote def forward(self, x:torch.Tensor) in the model

Correct way:

class LinearRegressionModel(nn.Module):
  def __init__(self):
    super().__init__()
…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@david-bickford
Comment options

Answer selected by david-bickford
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants