将 Keras 预训练模型扩展到具有附加通道或波段的图像

Extending a Keras Pre-trained model to images with additional channels or bands

我只是希望澄清有关之前 post 的一些信息,该内容讨论了如何将 Keras 预训练模型(如 VGG 或 InceptionV3)扩展到不同大小的图像。我的问题是我有一些 8 波段的卫星图像。因此图像可能是 650x650x8 而不是通常的 RBG 3 波段图像。我想知道我是否可以在具有 8 个波段而不是 3 个波段的图像上使用 Keras 预训练模型。

现在有一个原始的 post 并且处理与此类似的事情。参考 post 是关于将 Keras VGG 预训练模型应用于不同尺寸的图像。所以 VGG 是在 224x224x3 上训练的,用户想用这个模型来处理 160x320x3.

的图像

原文如下post:

这是原始代码 post:

from keras.models import Model
from keras.layers import Dense,Flatten
from keras.applications import vgg16
from keras import backend as K

model = vgg16.VGG16(weights='imagenet', include_top=False, input_shape=(160,320,3))
model.summary(line_length=150)

flatten = Flatten()
new_layer2 = Dense(10, activation='softmax', name='my_dense_2')

inp2 = model.input
out2 = new_layer2(flatten(model.output))

model2 = Model(inp2, out2)
model2.summary(line_length=150)

因此,如果我将第 6 行替换为:

model = vgg16.VGG16(weights='imagenet', include_top=False, input_shape=(650,650,8))

这行得通吗,或者预先训练的模型会不会接受通道的增加,因为它会接受图像高度或宽度的变化?

此外,我还必须对具有额外通道的模型进行额外的训练。但我不清楚预训练模型实际上是如何实现这个扩展的。添加的节点的权重只是设置为 0 还是某种初始化程序确定的权重?我正在尝试判断我需要做多少额外训练。

感谢任何提示或建议。

来自 Keras docs:

input_shape: optional shape tuple, only to be specified if include_top is False (otherwise the input shape has to be (224, 224, 3) (with 'channels_last' data format) or (3, 224, 224) (with 'channels_first' data format). It should have exactly 3 inputs channels, and width and height should be no smaller than 48. E.g. (200, 200, 3) would be one valid value.

您将无法将此 VGG 实现用于多光谱图像。正如您已经提到的,这会给尚未预训练的模型引入额外的权重。

多光谱图像的神经网络是一个非常活跃的研究课题,但恐怕很少有开箱即用的解决方案,例如在 imagenet 上预训练的网络。您可以尝试使用 PCA 等降维技术将图像压缩为三个通道。或者完全训练一个以 8 通道图像作为输入的自定义架构。