Modify Layer Name

I am loading ResNet50 using torchvision. However, I want to modify the layer names, specifically add a prefix before each name. Ex. layer1.0.conv1 -> prefix_layer1.0.conv1

Is it possible to do so for models imported from torchvision ?

Thanks

You could create a custom model and create the new child modules using the new attribute names and by assigning the pretrained torchvision modules.
This would also need changes in the forward method, since now all layers have different names.
Also, using this method you won’t be able to load the pretrained state_dict from torchvision's ResNet.

So, while it would be possible, I can’t think of a clean solution without some disadvantages.

What’s your use case that you need to change the attribute names?