[英]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 -类名 NeuralNet 和 self 关键字在 super 调用中传递的意思不一样吗 -
super(
NeuralNet ,
self ).__init__() # init super
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
Given your question, I kindly but very strongly suggest you do the full official Python tutorial .鉴于您的问题,我非常强烈地建议您阅读完整的官方 Python 教程。
And no, NeuralNet
and self
are NOT the same thing.不, NeuralNet
和self
不是一回事。 The first is the NeuralNet
class , the second is the current NeuralNet
instance ("current": the one on which the method has been called).第一个是NeuralNet
类,第二个是当前的NeuralNet
实例(“当前”:调用该方法的实例)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.