Hi.
Im trying to change module’s’
I know their relative name (model.layer.1.conv …)
And i have a target module that i want to overwrite to it
And they are saved as dict{name:module}
I know that i can change the model’s module by chagning attribute of it (ie model.layer[1].conv = nn.Conv2d(3,1,1,1))
But by calling getattr won’t to what i want to
names = [‘layer’, 0, ‘conv’]
For name in names:
Try:
Module = model[0]
Except:
Module = getattr(model, name)
The code isn’t complete but you can see that I’m trying to use getattr to get the attribute of the wanted layer and overwrite it with different layer
However, it seems like getattr gives a copy of an object, not the id.
So assigning module = nn.conv2d(3,1,1,1) won’t change the network
Is there any way to do this?
I have several modules to change and I can’t do them all by hand
Help much appreciated! Thx