Is Conv1D actually a convolution?

Hello all,
I am building a model that needs to perform the mathematical operation of convolution between the batches of 1D input c and a parameter, call it E.
Thus, I want something similar tonp.convolve(E,c) but in native pytorch . Am I taking i correctly, that Conv1D is not the right tool for the job? The documentation states it uses the valid cross-correlation operator insead of a convolution operator.
I found the following (at least) working solution to give reasonable yet wrong results:

conv = torch.nn.Conv1d(
    1, #number of batches
    1, #number of features (just 1)
    40, #length of the 1D kernel (E)
   padding=n_kernel - 1 #make it a "full" convolution or correlation, I guess

sol = conv(c[None, :])

Am I overlooking something and if so, how can I recreate the expected (numpy) behavior? And also, on a less serious note,why is it not called Cor1D then? :wink:
Thanks so much for your help!

1 Like

Flip the input or filter and you will perform a true convolution instead of a cross-correlation.