Hi Mahsa!



 mahsa:

I’m reading a code which has a class for Model and a class for Layer definition. The BaseClass of the Model is nn.Module and the BaseClass of Layer is Module from nn.modules.module. What is the difference?
Thanks


If I understand python correctly (which I don’t) nn.Module and
nn.Modules.Module are the same class.
As I understand it the module (in the python sense) nn.Module
in effect does:
from torch.nn.Modules import Module

This makes the name Module (from nn.Modules) visible in nn.
So, if in your code you have import torch.nn as nn, you can
in your code then refer to the class torch.nn.Modules.Module
as nn.Module.
Best regards.
K. Frank