I don’t know, however, how to access modules using layer_name variable.
So I suspect there’s some better way to do this. First, I’d like to list all the layers names (model.children() or model.named_parameters() don’t do this) and second, I’d like to use them somehow with the attached code.
Hello ptrblck!
I have an additional question…
I want to save inputs (or feature space) of each modules in a dictionary wise
so… for example if I have module names as model.layer1.conv1, model.layer1.conv2
I would like to save their input in a form of input['model.layer1.conv1'] = [input]
and append them as iteration goes input['model.layer1.conv1'].append(input)
I would like to do it with forward hook
I’m not sure if the code you presented here does the job for me
.named_modules() will return the name and module recursively for the complete model.
If you want to just register specific modules, such as nn.Conv2d but not e.g. BottleNeck or other custom modules, you could use a condition to check for the module via if isinstance().