I have a trained model and I want to do some surgery on it like merging layers into a fewer ones. For that, I need the following information for every layer in the model:
- layer class name - like nn.Conv2d, nn.BatchNorm2d or my custom classes.
- layer definition information - like what stride, what padding, bias true or false etc.
- layer parameters - like weights, bias, running mean & variance etc.
I have not been able to find a mechanism to get this consolidated information.
When I parse through the state dictionary, I only get a key and associated parameters. There is no way to find layer class/definition information from the key name. And when I use named_modules(), I get the layer information, but don’t get the key information to retrieve appropriate parameters from the state dictionary.
Appreciate your inputs, thanks!