Which part of Pytorch tensor represents channels?

The first number represents the Batchsize (N) and for tensors holding data of a dimension of 1 or above the next dimension is usually referred to as channel-dimension. The following dimensions are commonly height, width and depth.
So for 2d data (images) you have a 4d tensor of NxCxHxW which you feed into a 2d conv layer.

Note that channels only exist for convolutional layers. Linear layers for example need a shape of N x #num_features

7 Likes