有人知道为什么 input_shape 中的最后一个参数必须在 keras 的应用程序中指定为 3 吗?

Does anybody know why the last arg in input_shape must be specied 3 in keras' application?

我想使用预训练网络,例如VGG、ResNet。而在 Keras 中,必须在 input_shape 中指定 (w,h,3) 中的甲酸盐。如果我想指定通道为1,有没有更多的技巧?

conv_vgg = keras.application.VGG16(input_shape=(224,224,3))

我要指定3比1:

conv_vgg = keras.application.VGG16(input_shape=(224,224,1))

提前致谢!

在 imagenet 或其他图像数据集中训练的预训练网络。这意味着它是用 RGB 图像训练的,这就是使用预训练网络需要三个通道的原因。

如果您想对单个通道图像使用预训练网络,您可以重复您的通道三次并继续。 (重复复制两次你的 1 通道图像,从 (224,224,1) 形状到 (224,224,3) 形状(3 通道图像)。