Custom layer with specific matrix operation

I try to make my own layer with fixed kernel. I prepare kernel manually like in figure.
I want to find product from input and my kernel. But, product operations are not usual, only on the black part. for white, ignored. I dont need make it trainable for this layer.

So, it’s possible use torch.nn.Conv2d?


I think you may directly set the as your own kernel, then fix this layer.

1 Like

Thank you for your help, its working.