简体   繁体   中英

Activate dropout in a pre-trained VGG16 model

I'm using Tensorflow 2.0 and a pre-trained VGG16 model and want to activate dropout during prediction. So far I tried the following without success:

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)

However, none of these approaches worked. How can I enable dropout during the prediction phase?

The VGG16 architecture does not contain a dropout layer by default. You would need to insert a dropout layer in the model.

Here is a post I found useful to solve this: Add dropout layers between pretrained dense layers in keras

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM