【Inception-v3】《Rethinking the Inception Architecture for Computer Vision》

在这里插入图片描述

CVPR-2016
在 CIFAR-10 上的小实验可以参考博客【Keras-Inception v3】CIFAR-10



1 Background and Motivation

Although increased model size and computational cost tend to translate to immediate quality gains for most tasks (as long as enough labeled data is provided for training), computational efficiency and low parameter count are still enabling factors for various use cases such as mobile vision and big-data scenarios.

本文对GoogleNet 做了改进,目的是为了 computational efficiency

几种经典模型的尺寸,计算量和参数数量对比 1
在这里插入图片描述

2 Advantages / Contributions

describing a few general principles and optimization ideas to scale up convolution networks in efficient ways

design principles 是推测性(speculative)的,有待进一步的实验验证,但是如果严重偏离这些 principles 的话,效果会不好。所以设计网络的时候,见不贤而内自省也

design principles 具体如下

  • Avoid representational bottlenecks, especially early in the network. 即feature map的大小不应该出现急剧的衰减,信息过度的压缩,将会丢失大量的信息,对模型的训练也造成了困难。
    理论上 information content can not be assessed merely by the dimensionality of the representation(h×w×c),因为丢失了一些重要信息,例如 correlation structure。维度只能 rough estimate of information content.

  • Higher dimensional representations are easier to process locally within a network.
    在网络中对高维的表达进行局部的处理,将会使网络的训练增快。(3×3 = 1×3 + 3×1)

  • Spatial aggregation can be done over lower dimensional embeddings without much or any loss in representational power. 因为feature map上,临近区域上的表达具有很高的相关性,如果对输出进行空间聚合,那么将feature map的维度降低也不会减少表达的信息。这样的话,有利于信息的压缩,并加快了训练的速度。(5×5 = 两个 3×3)

  • Balance the width and depth of the network,要使得计算资源平衡的分配在模型的深度和宽度上面,才能最大化的提高模型的性能

3 Innovations

  • suitably factorized convolutions,5×5 = 两个 3×3,3×3 = 1×3 + 3×1
  • aggressive regularization,Label Smoothing

4 Method

  • suitably factorized convolutions
  • aggressive regularization

4.1 Factorizing Convolutions with Large Filter Size

4.1.1 Factorization into smaller convolutions

5×5 = 两个3×3
在这里插入图片描述

双 Relu vs linear + Relu ,前者胜
在这里插入图片描述

4.1.2 Spatial Factorization into Asymmetric Convolutions

能继续缩小吗?比如 3×3 = 2 个 2×2,可以。作者提出用 1×3+3×1,牛……

3 × 3 − 2 × 2 × 2 3 × 3 = 11 % \frac{3×3 - 2×2×2}{3×3} = 11\% 3×33×32×2×2=11%

3 × 3 − ( 1 × 3 + 3 × 1 ) 3 × 3 = 33 % \frac{3×3 - (1×3+3×1)}{3×3} = 33\% 3×33×3(1×3+3×1)=33%

在这里插入图片描述

升华下 n×n 压缩成 1×n + n×1,实验表明,grid-sizes 在12-20之间的时候用这种方法压缩比较有用,n用7

4.2 Utility of Auxiliary Classifiers

有趣的是,实验表明 Auxiliary Classifiers 并不能加速 converge,只是在训练快要结束的时候,the network with the auxiliary branches starts to overtake the accuracy of the network without any auxiliary.

更详细的讨论见 【Inception v1】《Going Deeper with Convolutions》 的 第8节GoogleNet

4.3 Efficient Grid Size Reduction

Grid Size 指的是 feature map 的 size(不算 channels),也即 W 和 H
我们要把 d × d × k → d 2 × d 2 × 2 k d \times d \times k \to \frac{d}{2} \times \frac{d}{2} \times 2k d×d×k2d×2d×2k
在这里插入图片描述

图中左边的结构先 pooling 再 convolution,operation(集中在 convolution)为 d 2 × d 2 × k × 2 k \frac{d}{2} \times \frac{d}{2} \times k \times 2k 2d×2d×k×2k

图中右边的结构先 convolution 再 pooling,operation(集中在 convolution)为 d × d × k × 2 k d \times d \times k \times 2k d×d×k×2k

Notice:operation 和 parameters 的区别,parameters 的计算只与 filter size 和 feature maps 的 channels 有关,与 feature maps 的 size 无关

虽然图中左边的结构 operation 少很多,但是 违背 principle 1(Avoid representational bottlenecks, especially early in the network)

作者的做法如下
在这里插入图片描述
这样做就避免了违背 principle 1

4.4 Inception-v3

caffe代码 + caffe代码可视化工具

在这里插入图片描述

reduction technique 见本博客4.3节图 10,表中的 inception 细节如下面图所示

把传统的第一步 7×7 变成了 3个 3×3


  • Inception-v1(原版)

在这里插入图片描述


重复3次
在这里插入图片描述

principle 3:Spatial aggregation can be done over lower dimensional embeddings without much or any loss in representational power.


重复5次
在这里插入图片描述

Principle 3:Spatial aggregation can be done over lower dimensional embeddings without much or any loss in representational power.


重复2次
在这里插入图片描述

Principle 2:Higher dimensional representations are easier to process locally within a network.


4.5 Model Regularization via Label Smoothing

  • label: k ∈ { 1... K } k \in {1...K} k1...K
  • softmax: p ( k ∣ x ) = e x p ( z k ) ∑ i = 1 K e x p ( z i ) p(k|x) = \frac{exp(z_k)}{\sum_{i=1}^{K}exp(z_i)} p(kx)=i=1Kexp(zi)exp(zk),其中 z i = w ∗ x + b z_i = w*x + b zi=wx+b
  • ground-truth distribution: q ( k ∣ x ) q(k|x) q(kx),且 ∑ k q ( k ∣ x ) = 1 \sum_{k}q(k|x) = 1 kq(kx)=1,因为只有一类为1,其它都为0
  • cross-entropy loss: l = ∑ k = 1 K q ( k ) ⋅ l o g ( p ( k ) ) l = \sum_{k=1}^{K}q(k)\cdot log(p(k)) l=k=1Kq(k)log(p(k))
  • gradient: ∂ l ∂ z k = p ( k ) − q ( k ) \frac{\partial l}{\partial z_k} = p(k) - q(k) zkl=p(k)q(k),参考 简单易懂的softmax交叉熵损失函数求导

假设某个样本的 label 为 y y y,作者发现,最小化 loss 等于最大化 l o g p ( k ) logp(k) logp(k),这样会导致 z y ≫ z k z_y \gg z_k zyzk,softmax 公式中可以看出 e x p ( z k ) exp(z_k) exp(zk) 是活力无限的(no limit)。logit corresponding to the ground-truth label is much great than all other logits. 这样会导致两个问题

  • result in over-fitting
  • reduces the ability of the model to adapt

Intuitively, this happens because the model becomes too confident about its predictions. 也可以理解为平时模拟的时候把某种题型做的太多了,太膨胀(得瑟)了!

为了那我们的model别那么得瑟(overfitting),作者提出了改进
上述的 q ( k ) = δ k , y q(k) = \delta_{k,y} q(k)=δk,y δ k , y \delta_{k,y} δk,y is Dirac delta( 狄拉克δ函数(Dirac delta)和狄拉克梳状函数(Dirac comb)

q ( k ) = { 1 k = y 0 k ≠ y q(k) = \left\{\begin{matrix} 1 & k=y\\ 0 & k\neq y \end{matrix}\right. q(k)={10k=yk=y

改进,加入了一个 u ( k ) u(k) u(k) distribution(论文中是 uniform distribution) 和 smoothing parameter ϵ = 0.1 \epsilon = 0.1 ϵ=0.1
在这里插入图片描述
u ( k ) = 1 K u(k) = \frac{1}{K} u(k)=K1,independent of the training example,with probability ϵ \epsilon ϵ, replace k with a sample drawn from the distribution u(k).
在这里插入图片描述
感觉改进是这样子的,把 0,1标签改得 soft target 一些(鄙人拙见),文中直观的说法是 all q′(k) have a positive lower bound.
在这里插入图片描述

作者把他叫做 label-smoothing regularization, or LSR.

在这里插入图片描述
LSR is equivalent to replacing a single cross-entropy loss H ( q , p ) H(q, p) H(q,p) with a pair of such losses H ( q , p ) H(q, p) H(q,p) and H ( u , p ) H(u, p) H(u,p).

进一步化简(参考 详解机器学习中的熵、条件熵、相对熵和交叉熵

  • H ( u , p ) = − u ⋅ l o g p = u ⋅ l o g 1 p H(u,p) = -u \cdot logp = u \cdot log \frac{1}{p} H(u,p)=ulogp=ulogp1,cross entropy——可以来衡量在给定的真实分布下,使用非真实分布所指定的策略消除系统的不确定性所需要付出的努力的大小
  • H ( u ) = − u ⋅ l o g u = u ⋅ l o g 1 u H(u) = -u\cdot logu = u \cdot log\frac{1}{u} H(u)=ulogu=ulogu1:信息熵
  • D K L ( u ∣ ∣ p ) = u ⋅ l o g u p D_{KL}(u||p) = u \cdot log \frac{u}{p} DKL(up)=ulogpu:相对熵(也叫 KL divergence)——可以用来衡量两个概率分布之间的差异。

从上面公式可以看出, H ( u , p ) = H ( u ) + D K L ( u ∣ ∣ p ) H(u,p) = H(u) + D_{KL}(u||p) H(u,p)=H(u)+DKL(up)

说明,作者改进版本添加的第二项就是 H ( u , p ) H(u,p) H(u,p) 指的是 p 和 u 概率分布之间的差距,让模型学习得雨露均沾一点,别那么一枝独秀(u 是 uniform 分布之后, H ( u ) H(u) H(u) 是定值)

− H ( p ) −H(p) H(p) 也能起到和 H ( u , p ) H(u,p) H(u,p) 相同的作用,p(softmax后的结果)越纯, H ( p ) H(p) H(p) 越小, − H ( p ) −H(p) H(p)越大,也惩罚了这种一枝独秀的情况。


label smoothing 的 pytorch 实现如下,参考 【Pytorch】label smoothinglabel smoothing理论及PyTorch实现

import torch
import torch.nn as nn
 
class NMTCritierion(nn.Module):
    """
    TODO:
    1. Add label smoothing
    """
    def __init__(self, label_smoothing=0.0):
        super(NMTCritierion, self).__init__()
        self.label_smoothing = label_smoothing
        self.LogSoftmax = nn.LogSoftmax()
 
        if label_smoothing > 0:
            self.criterion = nn.KLDivLoss(size_average=False)
        else:
            self.criterion = nn.NLLLoss(size_average=False, ignore_index=100000)
        self.confidence = 1.0 - label_smoothing
 
    def _smooth_label(self, num_tokens):
        # When label smoothing is turned on,
        # KL-divergence between q_{smoothed ground truth prob.}(w)
        # and p_{prob. computed by model}(w) is minimized.
        # If label smoothing value is set to zero, the loss
        # is equivalent to NLLLoss or CrossEntropyLoss.
        # All non-true labels are uniformly set to low-confidence.
        one_hot = torch.randn(1, num_tokens)
        one_hot.fill_(self.label_smoothing / (num_tokens - 1))
        return one_hot
 
    def _bottle(self, v):
        return v.view(-1, v.size(2))
 
    def forward(self, dec_outs, labels):
        scores = self.LogSoftmax(dec_outs)
        num_tokens = scores.size(-1)
 
        # conduct label_smoothing module
        gtruth = labels.view(-1)
        if self.confidence < 1:
            tdata = gtruth.detach()
            one_hot = self._smooth_label(num_tokens)  # Do label smoothing, shape is [M]
            if labels.is_cuda:
                one_hot = one_hot.cuda()
            tmp_ = one_hot.repeat(gtruth.size(0), 1)  # [N, M]
            tmp_.scatter_(1, tdata.unsqueeze(1), self.confidence)  # after tdata.unsqueeze(1) , tdata shape is [N,1]
            gtruth = tmp_.detach()
        loss = self.criterion(scores, gtruth)
        return loss

5 Dataset

ILSVRC-2012

6 Experiments

训练的时候用到了

  • RMSProp
  • gradient clipping with threshold 2.0

6.1 Performance on Lower Resolution Input

这里的实验我不是特别理解
在这里插入图片描述
在这里插入图片描述
结论:one might consider using dedicated high-cost low resolution networks for smaller objects in the R-CNN [5] context.

6.2 Experimental Results and Comparisons

ILSVRC-2012 validation set

在这里插入图片描述

v3-basic 不晓得是什么样的版本,auxiliary 分类器中加 BN还是可以的。注意红色框框是累积的实验结果,也就是后面的实验也有前面的实验的东西。Factorized 7 × 7 includes a change that factorizes the first 7 × 7 convolutional layer into a sequence of 3 × 3 convolutional layers.


solo 王
在这里插入图片描述


ensemble
在这里插入图片描述

7 Conclusion

several design proposal

ILSVRC-2012 上 state-of-art,2.5 × BN 计算量(v2)

  • Q1:4 个design principle 的形象化理解,结合图 5,6,7
  • Q2:softmax 中太过自信导致的两个问题的理解
  • Q3:6.1 小节 Lower Resolution Input 中 receptive filed 指的是什么意思呢?
  • Q4:关于 Auxiliary Classifiers 的思考,结合 【Inception-v1】《Going Deeper with Convolutions》 最后一小节 GoogleNet

附录(Spatial Factorization)

参考文章 一文读懂 12种卷积方法(含1x1卷积、转置卷积和深度可分离卷积等)
在这里插入图片描述
上面是 sobel 算子
1个 3 ∗ 3 3*3 33 可以分解成一个 1 ∗ 3 1*3 13 和 1个 3 ∗ 1 3*1 31

在这里插入图片描述
传统卷积计算量为: 3 ∗ 3 ∗ 3 ∗ 3 = 81 ( k e r n e l s i z e ∗ o u t p u t s i z e ) 3*3*3*3 = 81(kernel size * output size) 3333=81kernelsizeoutputsize
在这里插入图片描述
Spatial Factorization 的计算量 1 ∗ 3 ∗ 3 ∗ 5 + 3 ∗ 1 ∗ 3 ∗ 3 = 45 + 27 = 72 ( k e r n e l s i z e ∗ o u t p u t s i z e ) 1*3*3*5 + 3*1*3*3 = 45+27 = 72(kernel size * output size) 1335+3133=45+27=72kernelsizeoutputsize

泛化一下(kernel size 为 k k k,output size 为 h ∗ w h*w hw):

  • 正常卷积: k ∗ k ∗ h ∗ w k*k*h*w kkhw
  • Spatial Factorization convolution: k ∗ 1 ∗ ( h − k + 1 ) ∗ w + 1 ∗ k ∗ h ∗ w k*1*(h-k+1)*w + 1*k*h*w k1(hk+1)w+1khw

如果 h , w h, w h,w 远远大于 k k k,那么计算成本比为

2 ∗ k ∗ h ∗ w k ∗ k ∗ h ∗ w = 2 k \frac{2*k*h*w}{k*k*h*w} = \frac{2}{k} kkhw2khw=k2

缺点,尽管 Spatial Factorization convolution 能节省成本,但深度学习却很少使用它,主要原因是,并非所有的核都能分解成两个更小的核,如果用两个小核代替一个大核,会减少搜索所有可能的核,这样可能得到的结果不是最优的!


  1. 五种CNN模型的尺寸,计算量和参数数量对比详解 ↩︎

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: Inception 架构是一种用于计算机视觉的神经网络架构,它通过使用不同尺寸的卷积核来捕捉图像中的不同级别特征。近年来,研究者们对 Inception 架构进行了重新思考,提出了许多改进版本,如 Inception-v2 和 Inception-v3。这些改进版本通过更深层次的网络结构、更高效的卷积层、更强大的正则化方法等来增强模型的性能。 ### 回答2: "重新思考计算机视觉中的Inception架构"是指对计算机视觉中的Inception架构进行反思和重新设计的过程。 在计算机视觉中,深度学习网络被广泛应用于图像分类、物体检测和语义分割等任务。Inception架构是一种流行的深度学习架构之一,它的特点是使用了一系列不同尺寸的卷积核和Inception模块,以提取不同尺度下的图像特征。 然而,随着计算机视觉任务的不断发展和挑战的出现,人们开始重新思考和改进Inception架构。对Inception架构的重新思考主要包括以下几个方面: 首先,针对Inception架构中的参数数量过多和计算复杂度高的问题,人们提出了一些改进方法。例如,通过降低Inception模块中卷积核的维度和参数数量,可以减少计算量,提高网络的训练和推理效率。 其次,人们提出了一些新的模块和网络结构,以解决Inception架构在某些任务上的性能限制。例如,ResNet和DenseNet等网络结构通过引入残差连接和稠密连接,解决了深度网络中的梯度消失和信息丢失问题。 此外,人们还关注如何将Inception架构与其他架构进行融合,以进一步提升计算机视觉任务的性能。例如,人们将Inception架构与注意力机制相结合,以提高目标检测和图像分割的准确性。 总之,"重新思考计算机视觉中的Inception架构"是一个不断演进的过程。通过反思和优化Inception架构,人们可以提高计算机视觉任务的性能、准确性和效率,推动计算机视觉领域的发展。 ### 回答3: 重新思考计算机视觉中的初始架构(rethinking the inception architecture for computer vision)是指对计算机视觉模型中的初始网络架构进行重新思考和改进。 计算机视觉是人工智能领域中的一个重要分支,它致力于让计算机能够像人一样理解和处理图像和视频。而计算机视觉模型的架构对于模型的性能和效果具有很大的影响。 Inception架构是一种经典的计算机视觉模型架构,最早由谷歌在2014年提出。它通过使用多尺度的卷积层和并行结构来提高模型的性能和效果。然而,随着技术的发展和需求的变化,原始的Inception架构可能存在一些限制和缺陷。 重新思考Inception架构意味着我们需要针对当前的计算机视觉任务和要求,重新设计和改进Inception架构。有几个方面可以考虑: 首先,我们可以通过引入更先进的卷积技术和结构来改善模型的性能。例如,可以使用Dilated Convolution(空洞卷积)来增加感受野,或者使用Depthwise Separable Convolution(分离卷积)来减少参数量和计算量。 其次,我们可以将其他经典和有效的架构和思想与Inception架构相结合,以进一步提升性能。例如,可以引入残差连接(Residual Connection)来加快训练速度和提高模型的泛化能力。 此外,我们还可以针对具体的计算机视觉任务,对Inception架构进行特定的优化。例如,对于目标检测任务,可以加入适应性池化层(Adaptive Pooling Layer)来获得更好的位置和尺度信息。 总之,重新思考Inception架构是一个不断改进和优化计算机视觉模型的过程。通过结合新的技术、思想和任务需求,我们可以进一步提高计算机视觉模型的性能和效果。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值