self.bias = nn.Parameter(torch.zeros(10))
def forward(self, xb):
return xb @ self.weights + self.bias//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Since we"re now using an object instead of just using a function, we// first have to instantiate our model:
After Change
super().__init__()
self.lin = nn.Linear(784, 10)
def forward(self, xb):
return self.lin(xb)//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// We instantiate our model and calculate the loss in the same way as before: