maskrcnn_benchmark理解记录——关于batch norm、relu、dropout 的相对顺序以及dropout可不可用

本文讨论了在卷积神经网络中,Batch Normalization(BN)、ReLU和Dropout的相对顺序。BN应在ReLU之前,而Dropout通常在全连接层使用,对卷积层效果不佳。现代网络结构中,BN配合全局平均池化可减少过拟合,而Dropout应用减少。
摘要由CSDN通过智能技术生成

ps:

1.如何在卷积神经网络中实现全局平均池化。在此之前,建议阅读 ResNet这篇论文  ,以了解全局平均池化操作的好处。代替全连接层。

2.dropout只可能在box分支的两个全连接层那里,这个可以后期finetuning下。全连接网络可以使feature map的维度减少,进而输入到softmax,但是又会造成过拟合,可以用pooling来代替全连接。那就解决了之前的问题:要不要在fc层使用dropout。使用AVP就不要了。

目录

一、batch norm、relu、dropout 等的相对顺序

conv2d + init.weight→bn→relu

conv2d + init.weight and bias→ relu

conv→relu→..........→conv→relu

补充:pytorch的torch.nn.init 对参数和偏置初始化方式

 二、Dropout 层(2012年)与BN层 Dropout 层是否有效


一、batch norm、relu、dropout 等的相对顺序

在 Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift 一文中,作者指出,“we would like to ensure that for any parameter values, the network always produces activations with the desired distribution”(produces activations with the desired distribution,为激活层提供期望的分布)。

因此 Batch Normalization 层恰恰插入在 Conv 层或全连接层之后,而在 ReLU等激活层之前。而对于 dropout 则应当置于 activation layer 之后。

-> CONV/FC -> BatchNorm -> ReLu(or other activation) -> Dropout -> CONV/FC ->;

那么看到我的有几种方式,全部未用dropout:

  1. conv2d + init.weight→bn→relu

  2. conv2d + init.weight and bias→ relu

  3. conv→relu→..........→conv→relu

  • 第一种在ResNet.py
  1. 先在结构层定义了 conv2d、bn和并对conv2d进行nn.init.kaiming_uniform_(l.weight, a=1)处理。
  2. 然后结合在forword中看到结构是:conv2d + init.weight→bn→relu
        self.conv1 = Conv2d(
            in_channels,
            bottleneck_channels,
            kernel_size=1,
            stride=stride_1x1,
            bias=False,
        )
        self.bn1 = norm_func(bottleneck_channels)
      
        self.conv2 = Conv2d(
            bottleneck_channels,
            bottleneck_channels,
            kernel_size=3,
            stride=stride_3x3,
            padding=dilation,
            bias=False,
            groups=num_groups,
            dilation=dilation
        )
        self.bn2 = norm_func(bottleneck_channels)

        self.conv3 = Conv2d(
            bottleneck_channels, out_channel
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值