01_02_Notebook - Argument that seems extraneous to me #57
Christian-Stefan
started this conversation in
Weekly Notebooks
Replies: 1 comment
-
|
No other reason, the PyTorch developers used to do it so they wouldn't break all the code that's written in Python 2.x |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello.
Context:
MLP - which I understand is the name of our network class - has been passed as an argument to
super(). This seems unnecessary to me, or at least not the most logical choice. As far as I know, the role of anysuper().__init__()call is to initialize the parent class’s constructor - in this case, nn.Module() - such that we can eventually make use of whatever the parent class sets up.In older Python versions (e.g., Python 2.1), you had to explicitly reference the parent class whose constructor you wanted to initialize, but that requirement was removed once Python introduced the modern super() mechanism tied to the method resolution order (MRO).
class MLP(nn.Module):def __init__(self):super(MLP, self).__init__()Question:
In practice, I would normally use super().init(), and that works perfectly well. However, is there any other reason I might have overlooked that justifies passing MLP as an argument to super()?
Beta Was this translation helpful? Give feedback.
All reactions