Home > Blockchain >  Adding Dropout Layers to U_Net Segmentation_Models
Adding Dropout Layers to U_Net Segmentation_Models

Time:10-28

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

Thank you

CodePudding user response:

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)
  • Related