Hello
Imagine that I have a cube of ones:
cube = torch.Tensor(
[[[1,1,1],[1,1,1],[1,1,1]],
[[1,1,1],[1,1,1],[1,1,1]]
[[1,1,1],[1,1,1],[1,1,1]]])

I want to first “shift” each “layer”/2D Array contained in the cube along the dim1 axis, to obtain something like that (I then have to fill the “emptiness” by zeros):
cube = torch.Tensor(
[[[1,1,1,0,0],[1,1,1,0,0],[1,1,1,0,0]],
[[0,1,1,1,0],[0,1,1,1,0],[0,1,1,1,0]]
[[0,0,1,1,1],[0,0,1,1,1],[0,0,1,1,1]]])
Finally add the three layers of the cube to obtain a (3*5) array:
cube = torch.Tensor([[1,2,3,2,1],[1,2,3,2,1],[1,2,3,2,1]])
I can make a drawing to better explain the shifting part if I’m not clear.
I want to do it with any (x,y,z) tensor in the easier way. Can someone help me ?