【问题标题】:Unable to use EfficientNet with transfer learning无法将 EfficientNet 与迁移学习一起使用
【发布时间】:2021-08-09 00:50:47
【问题描述】:

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

【问题讨论】:

    标签: tensorflow keras conv-neural-network efficientnet


    【解决方案1】:

    我认为正在发生的事情是,对于 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 时,请务必移除像素值的任何重新缩放

    【讨论】:

      猜你喜欢
      • 2021-08-14
      • 2019-09-19
      • 2022-12-03
      • 2017-09-14
      • 2020-05-13
      • 2018-10-04
      • 2021-11-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多