Hi all,
Let’s say I have a tensor, with dims NxHxWxC, for this example 1x4x4x1. I’m trying to do some reshaping of the tensor with a sliding window. This window has a kernel size of k=3, which slides over the W and H dims. I want something like this
t = torch.Tensor([[
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, 15, 16],
]])
=>
[[
[1, 2, 3, 5, 6, 7, 9, 10, 11], # i.e. the top-left corner with k=3
[2, 3, 4, 6, 7, 8, 10, 11, 12], # one step to the left
…,
[6,7,8,10,11,12,14,15,16] # bottom-right corner with k=3
]]
The output dim should be N x ? x k **2 x C. If k=3, for this example, it should be 1x6x9x1.
Is this somehow possible, in an efficient way?
Thanks!