Hi,
I want to customize the kernel used in the conv2d layer in a way that shares parameters.
In short, I want the kernel to be symmetric with respect to the row in the middle and to the column in the middle.
If we take the example of 3 by 3 kernel. I want the third column to have the same parameters as the first one, and the third row to have the same params as the first one.
You could initialize the nn.Parameter
s in the model’s __init__
method, create the desired filter in the forward
(e.g. via torch.cat
and torch.stack
) and apply it via the functional API (F.conv2d
in your case).
That worked! thanks.