segmentation_models icon indicating copy to clipboard operation
segmentation_models copied to clipboard

dropout layer in Unet

Open nouha-mejri opened this issue 4 years ago • 1 comments

I'm using unet for semantic segmentation but my model is overfitting, so can I add a dropout layer for unet because I think that there isn't .

nouha-mejri avatar May 14 '21 19:05 nouha-mejri

Hello, 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)

luna9722 avatar May 15 '21 14:05 luna9722