Hi, I am using the pretrained Resnet50 wrapped by pretrainedmodels (https://pypi.org/project/pretrainedmodels/ 3)。
Now I want to access the intermidate result of each layer, I try the following code:
for module_pos, module in self.model._modules.items():
    if module is not None:
        x = module(x)  # Forward

However, there are two issues.
First, some of the layers in self.model._modules.items() is None (that is why I use  if module is not None:
Second, when I run the code, there is an error at the very last layer.
RuntimeError: size mismatch, m1: [2048 x 1], m2: [2048 x 1000] at /opt/conda/conda-bld/pytorch_1573049306803/work/aten/src/TH/generic/THTensorMath.cpp:197
How comes the pretrained model encountered with this problem? I know reshape m1 to [2048] may solve the problem. But why does this happen?
Thank you very much!