Customize Linear Operation in nn.Conv2d

Hi, currently I’m trying to replace all linear operation (i.e. y = WX + b) in a CNN with my own version. So far I can customize those linear operations in fully connected layers, but not the convolution layers. Is it possible to modify those in convolution layers?

We can’t help alot if you won’t tell how to modifyby ‘your version’, Try looking at functional nn maybe it’ll be a good place to start…

Actually, I want to use the hardware to perform this linear computation, and use the result in the CNN. In order to do this, I need to first ensure the linear operations can be replaced properly.

I have checked the document you provided, it seems the conv2d function has the form _add_docstr(torch.conv2d, …), and _add_docstr function is imported from torch._C library. I guess the convolution operation was implemented in C (correct me if I’m wrong). Does it mean I need to modify C code in order to achieve my goal?

You would probably be using gpu and it would be cuda modules…

Thanks for your reply. I think about it again, eventually I would like to replace the original linear operation (i.e. y = WX + b) with some additional noise (i.e. y = WX + b + n where n is some customized noise). Is there a simple way to do it for convolutional layers?