0

I am going through Udacity's Intro To Deep Learning with Pytorch course In the Neural Network part the instructor says that "in the init method, we need to call super, we need to do that because then PyTorch will know to register all the different layers and operation, if you don't do this part it wont be able to track the things that you are adding to your network and it wont work". Could you kindly elaborate and explain what exactly is the role of super keyword here and what does nn.Module inherits which helps in "keeping track" of changes.

Further the Jupyter notebooks says the following about use of super,

class Network(nn.Module):

Here we're inheriting from nn.Module. Combined with super().__init__() this creates a class that tracks the architecture and provides a lot of useful methods and attributes. It is mandatory to inherit from nn.Module when you're creating a class for your network. The name of the class itself can be anything.

  • please refer to the official docs https://pytorch.org/docs/stable/generated/torch.nn.Module.html – Maxim Lyuzin Jun 05 '22 at 07:23
  • you can read this: `https://stackoverflow.com/questions/576169/understanding-python-super-with-init-methods` – Salio Jun 05 '22 at 08:10

0 Answers0