Weights scaling by using conv layers

Hello everyone,

I am implementing a CNN for some experiments and would like to scale weights of a convolutional layer which is defined using nn.Conv2d(…) statement. So how can I scale magnitudes of the weights within a convolutional layer?

Thanks in advance!

You can access the weights of a module like so:

conv_layer = nn.Conv2d(3, 30, 3)
conv_weights = conv_layer.weight
# scaling weights in-place
scale_factor = 4