Inspecting a single tensor dimension

I have a weird output tensor with what seems to be an extra colour dimension.

The tensor is of shape T[4, 4, 300, 1200].

I would like to display purely the colour channels to understand what has happened and why there are 4 colour channels rather than 1.

So far I tried doing T[0, :, 0, 0] however I am uncertain whether it is correct.
Thank you!

Hi,

The last layer of your model decides your output. I am guessing you are using a CNN as you mentioned color–so, your last layer should have an output channel size of 1 if you want the output to be single channeled tensor. Something like nn.Conv2d(in_channels,1,kernel_size,stride,padding)

This would allow you to train, however , you would have extra weights which are not being trained against any loss function.

Thanks for the suggestion but it wasn’t for a Conv2d layer.
I was trying to place some images on the tensorboard!

The solution in my case was to remove the dodgy 4th colour channel by

T = T[ :, :3, :, : ]