在预训练的VGG16模型中激活辍学

时间:2020-03-01 12:29:38

标签: python tensorflow keras

我正在使用Tensorflow 2.0和预训练的VGG16模型,并希望在预测期间激活辍学。到目前为止,我尝试以下操作均未成功:

model = tf.keras.applications.VGG16(input_shape=(224, 224, 3), weights='imagenet', is_training=True)

model = tf.keras.applications.VGG16(input_shape=(224, 224, 3), weights='imagenet', dropout_rate=0.5)

但是,这些方法都不起作用。在预测阶段如何启用辍学?

1 个答案:

答案 0 :(得分:1)

默认情况下,VGG16体系结构不包含退出层。您需要在模型中插入一个辍学层。

这是我发现对解决此问题有用的帖子: Add dropout layers between pretrained dense layers in keras