无法将 EfficientNet 与迁移学习一起使用

Unable to use EfficientNet with transfer learning

我想在 Eurosat-rgb 数据集中使用 EfficientNet 进行迁移学习。我遇到的问题是它似乎没有学习。

首先,我从以下模型开始,使用 MobileNet 进行迁移学习,它运行良好 (1)

model_base = tf.keras.applications.MobileNet(weights='imagenet', include_top=False, input_shape=input_shape=(224,224,3))
model_base.trainable=False
model = tf.keras.Sequential([
  model_base,
  tf.keras.layers.GlobalAveragePooling2D(name="avg_pool"),
  tf.keras.layers.Dense(10, activation="softmax", name="predictions")
])

然后,我从 MobileNet 更改为 EfficientNetB1,突然它什么也没学到 (2)。 然后,如果我尝试使用 model_base.trainable=True,训练准确性会提高但验证准确性不会提高 (3).

我做错了什么?

如果我在没有迁移学习的情况下使用 EfficientNet,我也会得到很好的结果 (4),但显然会花费很多时间。 我也尝试过将优化器从 sgd 更改为 adam,但它都不起作用。

我认为正在发生的事情是,对于 Mobilenet,预处理功能将图像缩放到 -1 到 +1 之间。但是,对于 EfficientNetB1,位于 here 的文档指出

Note: each Keras Application expects a specific kind of input preprocessing.
For EfficientNet, input preprocessing is included as part of the model 
(as a Rescaling layer), and thus tf.keras.applications.efficientnet.preprocess_input
is actually a pass-through function.
EfficientNet models expect their inputs to be float tensors of pixels with values
in the [0-255] range.

因此,当您从 Mobilenet 更改为 Efficientnet 时,请务必删除像素值的任何重新缩放