How to change channel dimension of am image?
Suppose I have torch tensor with shape = [x,y,z,21] where x = batch_size, y = image_width, z= image_height. The above tensor represents batch of images with 21 channels. How should I convert it to size = [ x,y,z,3 ] ?

[x,y,z,21] -> [x,y,z,1] -> [x,y,z,3]

for segmentation results predicts with size [x,y,z,21] 

segmentation class index result with size [x,y,z,1]

# for pytorch, the right format for image is [batch, channels, height, width]
# however your image format [batch, height, width, channels]
result=predicts.argmax(-1)


the index combie the color map will help you! view voc color map for detial
