tensorflow - 密集连接层的 Dropout

标签 tensorflow machine-learning keras deep-learning densenet

我在我的一个项目中使用了密集网络模型,并且在使用正则化时遇到了一些困难。

如果没有任何正则化,验证和训练损失 (MSE) 都会减少。但训练损失下降得更快,导致最终模型出现一些过度拟合。

所以我决定使用dropout来避免过度拟合。使用 Dropout 时,验证和训练损失在第一个 epoch 期间均降至约 0.13,并在约 10 个 epoch 内保持恒定。

之后,两个损失函数都以与没有 dropout 时相同的方式减小,导致再次过拟合。最终的损失值与没有 dropout 的范围大致相同。

所以对我来说,dropout 似乎并没有真正起作用。

如果我切换到 L2 正则化,我能够避免过度拟合,但我宁愿使用 Dropout 作为正则化器。

现在我想知道是否有人经历过这种行为?

我在密集 block (瓶颈层)和过渡 block 中都使用了 dropout(dropout 率 = 0.5):

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

最佳答案

Without any regularization, both validation and training loss (MSE) decrease. The training loss drops faster though, resulting in some overfitting of the final model.

没有过度拟合。

当验证损失开始增加而训练损失持续减少时,过度拟合就开始了;这是其明显的签名:

enter image description here

该图片改编自Wikipedia entry on overfitting - 不同的事物可能位于水平轴上,例如提升树的深度或数量、神经网络拟合迭代的数量等。

训练和验证损失之间的(通常预期的)差异是完全不同的,称为 generalization gap :

An important concept for understanding generalization is the generalization gap, i.e., the difference between a model’s performance on training data and its performance on unseen data drawn from the same distribution.

实际上,验证数据确实是看不见的数据。

So for me it seems like dropout is not really working.

很可能是这种情况 - 辍学是 not expected始终致力于解决每一个问题。

关于tensorflow - 密集连接层的 Dropout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61043558/

相关文章:

machine-learning - 用于从给定文本中提取多个值的自学习解决方案

Tensorflow CIFAR10 多 GPU - 为什么是组合损失?

python - 具有多个输入的 Keras 网格搜索

python - Pytorch:如何创建不是来自衍生品的更新规则?

python - google ml engine scale-tier 未在远程分布式训练中运行

ipython - 在 Ubuntu 中移动 .keras 目录

r - 错误消息 AttributeError : module 'tensorflow' has no attribute 'VERSION'

python - 具有不同输入大小的 Keras 共享层

tensorflow - 属性错误 : module 'tensorflow' has no attribute 'Session'

TensorFlow 精简版 : High loss in accuracy after converting model to tflite