We all know that convolution operator is just a linear operator acting in sliding window way.
I am trying to implement SimNet Convolotion, which apply merely lp norm before the linear operation.
Or we can say, the original 1d convolution is:
And I want:
What’s the best way to do in pytorch?
I’m afraid you have to implement the convolution yourself in python using the already available pytorch functions as the Convolutions are implemented in C.
Alternatively you could have a look at the C-Implementation which can be found here and check whether it would be easier to modify this implementation. On this tutorial page you can find examples towards how to extend pytorch.
I think the best approach would be to write your own autograd function as suggested in this post
Thank you for your advice.
The C-implementation way is little tricky, for I found the pytorch->torch->Aten->CUDNN dependency chain,, which I am not good at.
The autograd way looks easy. But I have to use for loop to implement it. Well, I will try, thank you.