Hi Mahsa!



 mahsa:

Thanks K Frank. I added the link of the codes.


Thanks for the link to the layer code.  That clears things up.
Yes, the two Module classes are indeed one and the same.
Look specifically at this line in layers.py
from torch.nn.modules.module import Module

So let me go back to a version of my first reply to you – there is
a class torch.nn.modules.module.Module and the package
(python “module”) torch.nn imports it, making it visible as
torch.nn.Module.
To see what’s going on, run this script:
from torch.nn import Module as NnModule
print ('NnModule =', NnModule)
from torch.nn.modules.module import Module as MModule
print ('MModule =', MModule)

When I run this I get:
NnModule = <class 'torch.nn.modules.module.Module'>
MModule = <class 'torch.nn.modules.module.Module'>

So, the package torch.nn is, in effect, doing something like
from torch.nn.modules.module import Module

and this makes torch.nn.modules.module.Module visible as
torch.nn.Module.
(I was getting tangled up a little bit before with the
modules.module.Module and the capitalization.)
Best regards.
K. Frank