anonymous
anonymous

Reputation: 189

different between class name vs self calling in super()

isn't it same meaning of class name NeuralNet and self keyword passing in super call -
super(NeuralNet,self).__init__() # init super

here is the code snippet from example:

class NeuralNet(nn.Module):
    def __init__(self, use_batch_norm, input_size=784, hidden_dim=256, output_size=10):
        """
        Creates a PyTorch net using the given parameters.
        """
        super(NeuralNet, self).__init__() # init super
        # continues code

Upvotes: 0

Views: 161

Answers (1)

bruno desthuilliers
bruno desthuilliers

Reputation: 77912

Given your question, I kindly but very strongly suggest you do the full official Python tutorial.

And no, NeuralNet and self are NOT the same thing. The first is the NeuralNet class, the second is the current NeuralNet instance ("current": the one on which the method has been called).

Upvotes: 2

Related Questions