我在我的一个项目中使用了一个密集网络模型,并且在使用正则化时遇到了一些困难。
如果没有任何正则化,验证和训练损失 (MSE) 都会减少。但是,训练损失下降得更快,导致最终模型出现一些过度拟合。
所以我决定使用 dropout 来避免过拟合。使用 Dropout 时,在第一个 epoch 期间验证和训练损失都减少到大约 0.13,并在大约 10 个 epoch 内保持不变。
之后,两个损失函数都以与没有 dropout 相同的方式减小,从而再次导致过度拟合。最终的损失值与没有 dropout 的范围大致相同。
所以对我来说,辍学似乎并没有真正起作用。
如果我切换到 L2 正则化,我能够避免过度拟合,但我宁愿使用 Dropout 作为正则化器。
现在我想知道是否有人经历过这种行为?
我在密集块(瓶颈层)和过渡块(辍学率 = 0.5)中都使用了 dropout:
def bottleneck_layer(self, x, scope):
with tf.name_scope(scope):
x = Batch_Normalization(x, training=self.training, scope=scope+'_batch1')
x = Relu(x)
x = conv_layer(x, filter=4 * self.filters, kernel=[1,1], layer_name=scope+'_conv1')
x = Drop_out(x, rate=dropout_rate, training=self.training)
x = Batch_Normalization(x, training=self.training, scope=scope+'_batch2')
x = Relu(x)
x = conv_layer(x, filter=self.filters, kernel=[3,3], layer_name=scope+'_conv2')
x = Drop_out(x, rate=dropout_rate, training=self.training)
return x
def transition_layer(self, x, scope):
with tf.name_scope(scope):
x = Batch_Normalization(x, training=self.training, scope=scope+'_batch1')
x = Relu(x)
x = conv_layer(x, filter=self.filters, kernel=[1,1], layer_name=scope+'_conv1')
x = Drop_out(x, rate=dropout_rate, training=self.training)
x = Average_pooling(x, pool_size=[2,2], stride=2)
return x