Why is always the numer of input channels 3

For nn.Conv2D, why we have always input channel set to 3:

Examples:

AlexNet(
  (features): Sequential(
    (0): Conv2d(3, 64, kernel_size=(11, 11), stride=(4, 4), padding=(2, 2))

ResNet(
  (conv1): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)

SqueezeNet(
  (features): Sequential(
    (0): Conv2d(3, 96, kernel_size=(7, 7), stride=(2, 2))

VGG(
  (features): Sequential(
    (0): Conv2d(3, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))

DenseNet(
  (features): Sequential(
    (conv0): Conv2d(3, 96, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)

Inception3(
  (Conv2d_1a_3x3): BasicConv2d(
    (conv): Conv2d(3, 32, kernel_size=(3, 3), stride=(2, 2), bias=False)

And so on you get the point?

It’s because an image that is in color has three channels, RGB - or Red Green Blue. Most networks operate on color images

Is this the same for CMY?

I’ve never done it, but I guess that if you want to use another colorspace, such as CMY, you could still use the network architecture but would have to retrain the networks yourself. Or, was this what you were wondering?

Thanks @Oli, I don’t plan to work on CMY, at the moment, just checking if this would be possible. NFQ. (no further questions).

1 Like

Images can also be converted to greyscale and then the number of input channels will be 1.