I am using densenet-121 model from scratch to create the model for image classification problem. the code is shown below:
def bn_r1_conv(x,filters,kernel=1,strides = 1):
x = BatchNormalization()(x)
x = ReLU()(x)
x = Conv2D(filters,kernel,strides = strides,padding = 'same')(x)
#x = Drop_out(x, rate=0.2)
x = tf.keras.layers.Dropout(0.2)(x)
return x
def dense_block(x,repetition):
for _ in range(repetition):
y = bn_r1_conv(x,4*filters)
y = bn_r1_conv(y,filters,3)
x = concatenate([y,x])
return x
def transition_layer(x):
x = bn_r1_conv(x,K.int_shape(x)[-1]//2)
x = AvgPool2D(3,strides = 2,padding = 'same')(x)
return x
My model is overfitting. so I want to use dropout in the model. It would be helpful if someone fix my problem. thanks in advance.