Named_modules can't get all the layer

Hi, Today I try use the named_modules to get the all layer from the net

like this:

for name, layer in net.named_module():
    print(name, layer)

this can’t print the all layer ?

.named_module is not a valid method and you should use .named_modules instead which will print all registered modules as seen here:

model = models.resnet18()
for name, layer in model.named_modules():
    print(name, layer)
1 Like