Hi,
You don’t need to write a backward.
You can write a custom nn.Module that inherits from nn.Conv2d.
Then modify the forward to take an extra argument, get the masked weights and call functional.conv2d to evaluate the convolution with these new weights then return that.