Hello,
I am trying to use nn.Unfold to build a customized non-linear (max) convolution over 1-D tensors. This is my code:
import torch
import torch.nn as nn

xx = torch.Tensor([4,5,7,6,4,3,4,2,0,2,4,5,6,7,8])
xx_as4D = xx.view(1,1,1,-1)
unfold = nn.Unfold(kernel_size=(1,4), dilation=(1,1), padding=(1,3), stride=(1,1))
xx_unf = unfold(xx_as4D)

print(f'xx_unf.shape = {xx_unf.shape}')
print(f'xx_as4D.shape = {xx_as4D.shape}')

and the output

xx_unf.shape = torch.Size([1, 4, 54])
xx.shape = torch.Size([15])
xx_as4D.shape = torch.Size([1, 1, 1, 15])

Following the docs 1, I was expecting that the output of unfold() would be of size [1,4,18], but I am getting the size [1,4,54]. Could some please help me figure out where is my flaw?
In addition, if you have suggestions or references about how to accomplish my goal in an efficient way on Pytorch, those will be welcome!  Thanks.