How do I parse parameters of BatchNorm2d?

I want to extract every parameters of certain BatchNorm2d layer from pretrained model, like epsilon, input size, momentum etc…

Then, I will feed the extracted parameters to my new BatchNorm2d layer from different model.(let say this is target model)

I don’t think torch.save&load won’t work for this case cuz the pretrained model and target model have different architecture.

How do I parse parameters of BatchNorm2d?

You could get all attributes from the original batch norm layer simply by accessing them:

bn = nn.BatchNorm2d(3)
print(bn.eps)
print(bn.momentum)
...