How can I chunk a PyTorch tensor into a specified bucket size with overlap?
Specifically, I have a tensor of shape: torch.Size([1, 16])
I want to bucket this into 7 buckets (of 4 each). Example:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
should become:
[[1, 2, 3, 4],
 [3, 4, 5, 6],
 [5, 6, 7, 8],
 [7, 8, 9, 10],
 [9, 10, 11, 12],
 [11, 12, 13, 14],
 [13, 14, 15, 16],
]

How can I achieve this with PyTorch?

Looks like an unfold:
t.unfold(0,4,2)

Output:
tensor([[ 1.,  2.,  3.,  4.],
        [ 3.,  4.,  5.,  6.],
        [ 5.,  6.,  7.,  8.],
        [ 7.,  8.,  9., 10.],
        [ 9., 10., 11., 12.],
        [11., 12., 13., 14.],
        [13., 14., 15., 16.]])

