Solved by ptrblck in post #4 
              
              
                If you would like to use a sliding window of kernel size k, you could try the following code (originally created by @fmassa) : 
n, c, w, h = 1, 3, 24, 24
k = 3
stride = 1
x = torch.randn(n, c, w, h)
input_windows = x.unfold(2, k, stride).unfold(3, k, stride)
print(input_windows.shape)
> torch.Size([…