Reverse the Tensor channel

For below tensor i want to reverse the channel.
Note: Sequence of tensor value should remain as it is just channel should be reverse and tensor could be of variable length channel and it is known. Here channel is 3. It could be 6 or 7. Input -Output should be

in=torch.tensor([[[[1., 2.],
          [3., 4.]]],


        [[[11., 12.],
          [13., 14.]]],


        [[[21., 22.],
          [23., 24.]]]])
out=torch.tensor( [[[21., 22.],
          [23., 24.]]]],


        [[[11., 12.],
          [13., 14.]]],


       [[[[1., 2.],
          [3., 4.]]])

torch.flip might be the answer you are finding.

in = torch.rand(a, b, c)
out = torch.flip(in, [0, 1])
1 Like