Why are modules inherited completely in pytorch linear regression constructor?

Viewed 26

I've been trying to understand this piece of code here for a bit:

    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 

why is the initialisation of the torch.nn.Module being inherited completely into this class? how does this help when self.linear is calling functions used for the module straight from torch.nn.linear anyways? Would be awesome if somebody could give an explanation on this!

0 Answers
Related