Hello, I am wondering wich of these two ways is the best for changing a module’s submodule:
Here I want to change model’s “conv” module to a new convolution (different in and out sizes)
with torch.no_grad():
new_conv = nn.Conv2d(...)
W = nn.Parameter(new_conv.weight, requires_grad=True)
model.conv1.weight = W
with torch.no_grad():
new_conv = nn.Conv2d(...)
model.conv1 = new_conv
Are both ways equivalent or there’s a better one? (in the case that none of the convolutions have a bias)