I have the following simple example code for linear regression as follows.import torch
import numpy as np from torch.autograd import Variable class linearRegression(torch.nn.Module): def __init__(self, inputSize, outputSize): super(linearRegression, self).__init__() self.linear = torch.nn.Linear(inputSize, outputSize) def forward(self, x): out = self.linear(x) return out x = np.array(, dtype = np.float32).reshape(-1, 1) x = Variable(torch.from_numpy(x)) model = linearRegression(1, 1) model(x)
the output is
My question is how the output is made by not
In this code I have never called
forward, but it seems to be called.
It is because the dunder method
nn.Module will internally call its user-defined