1

我想在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,但它也不起作用。

4

1 回答 1

1

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

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 时,请务必删除像素值的任何重新缩放

于 2021-05-19T20:39:50.340 回答