Your current code snippet will create patches with the length of 5 samples and a stride of 1.
Since dim2 has 10 values, you will end up with 6 patches.
Simplified explanation
data = torch.arange(10).view(1, 1, 10).float()
patches = data.unfold(2, 5, 1)
print(patches)
> tensor([[[[0., 1., 2., 3., 4.],
          [1., 2., 3., 4., 5.],
          [2., 3., 4., 5., 6.],
          [3., 4., 5., 6., 7.],
          [4., 5., 6., 7., 8.],
          [5., 6., 7., 8., 9.]]]])




 madarax64:

If the filter itself was to have trainable weights (just like traditional convolution), then I would have to declare the filter as being a Tensor, right?


You could define it as a tensor with requires_grad=True or directly as nn.Parameter(torch.randn(...)) and pass it to your optimizer.