Get previous layer from batch normalization layer

Hi guys,

I am using batch normalization weights as scores of the channel importance of previous convulotional layer, similarly to what is done in some network pruning methods.
My objective is to single out the convulotional layers that have the lowest channel importance and get its weights. In essence, the problem is: How do I get the convulotional layer’s channel that is attatched to the lowest weight of the following batch normalization layer.

I’m not sure, if I understand the use case completely.
If your batchnorm layer takes e.g. 6 input channels, and bn.weight[1] has the lowest value, it would correspond to conv.weight[1] of the preceding layer.

Thank you for the reply!
Not always, there can be more then one convulotional layer connecting to the batch normalization layer and they can come from any previous layer. Dense net, for example does this. Where you have cnv1 and cnv2 connecting to bnorm1 and cnv1 connevting to cnv2 (If Im not mistaken).

That might be the case, so could you please post a code snippet for your use case?