class LinearRegressionModel(nn.Module):
def __init__(self):
super().__init__()
self.weight=nn.Parameter(torch.randn(1,requires_grad=True,dtype=torch.float))
self.bias=nn.Parameter(torch.randn(1,requires_grad=True,dtype=torch.float))
def forward(self, x: torch.Tensor)->torch.Tensor:#"x is the input data"
return self.weights*x+self.bias#y=weight*x+bias
a=LinearRegressionModel()
Trying to run this basic code Getting This Error
TypeError Traceback (most recent call last)
Cell In[18], line 1
----> 1 a=LinearRegressionModel()
Cell In[17], line 8, in LinearRegressionModel.init(self)
4 def init(self):
6 super().init()
----> 8 self.weight=nn.Parameter(torch.randn(1,requires_grad=True,dtype=torch.float))
9 self.bias=nn.Parameter(torch.randn(1,requires_grad=True,dtype=torch.float))
TypeError: ‘Tensor’ object is not callable