How to compress [B,C,H,W] to [B,H,W]

i have b,c,h,w image and i want to b,h,w size for segmentation without loss of information.i try to squeeze func but not working.
thanks for comments

Hi Akcaymert!

You can’t. [B, C, H, W] consists of B * C * H * W numbers, while
[B, H, W] consists of B * H * W, which is fewer (assuming that C > 1).

So, unless your original [B, C, H, W] data have some substantive
redundancy that you haven’t told us about, your desired compression
will lose information.


K. Frank

I think I expressed it wrong. actually, i have masking image (3xwxh). tried combining all the masked pictures for example
(tab is not important)

image = np.zeros((predicted.size()[0],224,224))
            for i in range(predicted.size()[0]): # i is a batch 
              for j in range(predicted.size()[1]): # j is a masking dim 
                image[i] += predicted[i,j].detach().numpy()
            predicted = torch.tensor(image,requires_grad=True)