Submitted by AutoModerator t3_xznpoh in MachineLearning
ABCDofDataScience t1_isi9ke4 wrote
Question: What exactly does Pytorch super(My_Neural_Network,self).__init__() do such that we need to include it in all Neural networks init() method?
After looking up online, all I found is: It initializes some special properties that are required for Neural Network but couldn't find any solid answer that describes in detail.
itsyourboiirow t1_iskqchc wrote
Yeah I’m not sure about the details. But I would guess it’s so you can use back propagation and loss functions on your NN.
ThrowThisShitAway10 t1_iso6km8 wrote
This is a feature of Python, not just PyTorch. We use the super function because we want our class to inherit the attributes of it's parent. For your PyTorch module to work, you have to inherit from the nn.Module class. It's not a big deal
seiqooq t1_it40uw6 wrote
It’s a bit of a rabbit hole, but this is required for autograd to create the reverse computation graph (enables backpropagation). PyTorch has great videos on YouTube if you want to dig in, just search PyTorch autograd.
Viewing a single comment thread. View all comments