Sorry,  I didn’t mean to confuse you. I made a mistake in my last post.



 ptrblck:

Also, which model are you using?


I’m using vgg16 for cifar10 and I choose the same layer to compare the gradients.



 ptrblck:

I assumed it’s vgg16 and if that’s the case, features[30] is an nn.MaxPool2d layer, without any weight and bias parameters.


Yeah, as you said, there isn’t any weight and bias parameters in features[30]. So I choose features[37], which is Conv2d layer in my model.



 AndrewSoul:

class ModelOutputs():



I defined m_o like:
m_o = ModelOutputs (model, target_layers=['37'])
So I compared the gradient of  ModelOutputs in layer[‘37’] and model.features[37].weight.grad.
The shapes are different, like I said in my last post:



 AndrewSoul:

self.weight = Parameter(torch.Tensor(
out_channels, in_channels // groups, *kernel_size))


And  m_o.gradients: shape: (N, Cout, Hout, Wout)
Maybe, that can explain the difference in shape?  Did I make myself understood?