Adding Dropout Layers to U_Net Segmentation_Models

Question:

I am using U_Net segmentation model for medical images segmentation with Kersa and Tensorflow 2. I’d like to add a dropout to the model, but I don’t know where to add it?

Asked By: Emy Ibrahim

||

Answers:

Yes there isn’t dropout layers in the implementation of unet, but you can use regularizers

set_regularization(model, kernel_regularizer=keras.regularizers.l2(0.001),bias_regularizer=keras.regularizers.l2(0.001))

you can also try data augmentation. But if it is necessary to add dropout you can stop after some layers and add after it the dropout layers you want like this:

model = sm.Unet(......)
model_input = model.input
model_output = model.get_layer('final_conv').output (any layer you want)
#add dropout
model_output = keras.layers.Dropout(0.3)(model_output)
#add activation
output = keras.layers.Activation(activation, name=activation)(model_output)
model_dp = keras.models.Model(model_input, output)
Answered By: Faisal Shahbaz