I’m not sure what you mean by self.module in your title…
The self.modules() method returns an iterable to the many layers or “modules” defined in the model class. This particular piece of code is using that self.modules() iterable to initialize the weights of the different layers present in the model. isinstance() checks if the particular layer “m” is an instance of a conv2d or linear or conv3d layer etc. and initializes the weights accordingly.
Why don’t you check the docs for all these functions to get a better understanding?
model.modules()
model.named_modules()
model.parameters()
model.named_parameters()
model.children()
model.named_children()