The tensor should be updated with additional row-zeros (bottom) and column-zeros (on the right side).
My solution will be provided below. Is there any better (actually simpler) one?
input: («ones» are just for clarification - figures might be different, because in my case there is a tensor exactly the same size but with real values in it)
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.]]]])
output:
tensor([[[[1., 1., 1., 0.],
[1., 1., 1., 0.],
[1., 1., 1., 0.],
[0., 0., 0., 0.]],
[[1., 1., 1., 0.],
[1., 1., 1., 0.],
[1., 1., 1., 0.],
[0., 0., 0., 0.]],
[[1., 1., 1., 0.],
[1., 1., 1., 0.],
[1., 1., 1., 0.],
[0., 0., 0., 0.]]]])
possible solution:
x1 = torch.ones(1, 3, 3, 3)
z2 = torch.cat((torch.cat((x1[0, 0, :], torch.zeros(1, 3)), 0), torch.zeros(4, 1)), 1)
z3 = torch.cat((torch.cat((x1[0, 1, :], torch.zeros(1, 3)), 0), torch.zeros(4, 1)), 1)
z4 = torch.cat((torch.cat((x1[0, 2, :], torch.zeros(1, 3)), 0), torch.zeros(4, 1)), 1)
output_t = torch.zeros(1, 3, 4, 4)
output_t[0, 0, :] = z2
output_t[0, 1, :] = z3
output_t[0, 2, :] = z4
output_t