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

article/2025/11/8 20:25:07

在这里插入图片描述

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


文章目录

  • 1 Background and Motivation
  • 2 Advantages / Contributions
  • 3 Innovations
  • 4 Method
    • 4.1 Factorizing Convolutions with Large Filter Size
      • 4.1.1 Factorization into smaller convolutions
      • 4.1.2 Spatial Factorization into Asymmetric Convolutions
    • 4.2 Utility of Auxiliary Classifiers
    • 4.3 Efficient Grid Size Reduction
    • 4.4 Inception-v3
    • 4.5 Model Regularization via Label Smoothing
  • 5 Dataset
  • 6 Experiments
    • 6.1 Performance on Lower Resolution Input
    • 6.2 Experimental Results and Comparisons
  • 7 Conclusion
  • 附录(Spatial Factorization)


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 smoothing 和 label smoothing理论及PyTorch实现

import torch
import torch.nn as nnclass NMTCritierion(nn.Module):"""TODO:1. Add label smoothing"""def __init__(self, label_smoothing=0.0):super(NMTCritierion, self).__init__()self.label_smoothing = label_smoothingself.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_smoothingdef _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_hotdef _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 modulegtruth = 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模型的尺寸,计算量和参数数量对比详解 ↩︎


http://chatgpt.dhexx.cn/article/h99CB94K.shtml

相关文章

DynamicViT

又搬来了来自清华大学与UCLA的工作&#xff0c;提出了一种基于动态token稀疏化的高效视觉transformer&#xff0c;通过分层剪枝66%的输入tokens&#xff0c;可减少31%~37%的FLOPs&#xff0c;并将模型运行速度提高了40%以上&#xff0c;保证精度下降在0.5%以内&#xff0c;可应…

involution理解

最好的参考来自论文作者的知乎&#xff1a;CVPR 2021 | involution&#xff1a;超越convolution和self-attention的神经网络新算子 其他餐卡&#xff1a; https://zhuanlan.zhihu.com/p/400402288 https://zhuanlan.zhihu.com/p/356960359 https://blog.csdn.net/P_LarT/articl…

网络中的pvid与native vlan(本征vlan)区别以及详解

一&#xff1a;pvid与native vlan分别属于华为和思科交换里面的概念&#xff0c;虽然说法不同&#xff0c;但是本质都是缺省vlan 缺省vlan默认为1&#xff0c;各个端口都有一个缺省的vlan&#xff0c;该值支持修改。 2.作用概念&#xff0c;pvid存在于trunk中&#xff0c;且&…

VTP、PVID、ACCESS、trunk

一、VTP详解 VTP有server、client、transparent三种模式、VTP多用于在多vlan的网络环境中&#xff0c;在核心交换机或者根节点交换机中配置Server&#xff0c;在下层的交互机中配置client&#xff0c;VTP在服务模式下&#xff0c;可以创建、删除、修改VLAN&#xff0c;并且转发…

不同VLAN下实现网络互相通信(配置port trunk pvid vlan进行数据转发)

1. 两台交换机同一网段&#xff0c;不同VLAN实现网络互通&#xff0c;逻辑拓扑图如下&#xff1a; 需求&#xff1a;实现VLAN 10与VLAN20之间的PC网络互通 在LSW 12交换机进行如下命令行配置&#xff1a; <HuaWei>system-view #切换系统视图 [Huawei]sysname…

VLAN Tag,PVID

VLAN(Virtual Local Network&#xff0c;虚拟局域网)&#xff0c;对于VLAN的划分方法有很多种&#xff1a;基于端口划分&#xff0c;基于MAC地址划分&#xff0c;基于网络协议划分&#xff0c;基于IP地址划分&#xff0c;基于策略划分等等。但是就上述而言&#xff0c;对VLAN的…

trunk vlan pvid 学习实验整理 2

实验总结&#xff1a; trunk vlan vlan1 vid pvid 等关系。 实验场景二&#xff1a; 上述条件不变【实验场景一】&#xff0c;将PC1 加入vlan10 [SW1]interface Ethernet 0/0/1 [SW1-Ethernet0/0/1]port link-type access [SW1-Ethernet0/0/1]port default vlan 10 >>…

trunk vlan pvid 学习实验整理 1

实验总结&#xff1a; trunk vlan vlan1 vid pvid 等关系。 实验场景一&#xff1a; 将PC1/PC2/PC3,都置于同一网段&#xff1a;192.168.1.0/24 1.PC1 不加入任何vlan&#xff0c;PC2 不加入任何vlan&#xff0c;PC3加入vlan10 2.trunk链路允许vlan 10 20通过。 配置&#xf…

PVID(pvid vlan是什么意思)

26tpwinet如何设置端口pvid25口设置为trunk口&#xff1f; 首先你要确定你的电脑有没有USB转com口线&#xff0c;或者你的笔记本是否支持com口 如果你是win7系统确实没有超级终端那么你可以下一个SecureCRT&#xff0c;然后在设备管理器里面看一下自己是COM几口&#xff0c;波…

PVID和VID的理解

VID解释 VID&#xff08;VLAN ID&#xff09;是VLAN的标识&#xff0c;在交换机里面用来划分端口。比如一个交换机有8个端口&#xff0c;现在将port1&#xff0c;port2&#xff0c;port5三个端口的VID设置成1111&#xff0c;那么这三个端口就能接收vlantag1111的数据包。   …

2、PVID(本征VLAN)实验配置步骤

实验拓扑图&#xff1a; 实验配置思路&#xff1a; 将VLAN10配置为本征VLAN 本征VLAN通过Trunk接口时不打tag标记 实验摘要重点命令&#xff1a; [SW1]int g0/0/1 //进入接口 [SW1-GigabitEthernet0/0/1]port trunk pvid vlan 10 //将VLAN10设置为本征VLAN [SW1-Gig…

华为交换机PVID与VLAN ID及TAG 、UNTAG学习记录

一、PVID和VLAN ID 1、PVID是端口的属性&#xff0c;端口的标识&#xff0c;具有唯一性&#xff0c;交换机默认未配置Vlan的情况下&#xff0c;因为全局vlan1的原因&#xff0c;所有端口的PVID都是1。如下图&#xff1a; 2、交换机里面display port vlan命令可以查看未配置状态…

switch中的PVID、VID、untag、tag概念

以openwrt为例&#xff0c;下图是mt7621&#xff08;glinet mt1300&#xff09;中switch配置图 该switch一共有7个port&#xff0c;一个连接CPU&#xff0c;还有6个可供外部使用&#xff0c;上图只显示了6个port&#xff1b; 一个switch可以设置多个VLAN&#xff08;虚拟局域网…

springboot @Qualifier 注解的作用

Qualifier 注解的用法和要解决的问题 现在这两个类都实现了同一个接口。 controller 要注入这个接口 启动服务日志显示在容器中找到俩个实现类 spring不知道要实现那个 1 有两种方式 既然spring不知道那就直接指明你要实现的类 直接注入实现类 这样有点粗鲁 也能解决问题。…

Spring中的@Qualifier注解

国庆期间闲来无事&#xff0c;写了一个简单的小程序&#xff0c;小程序名称叫做 IT藏经楼。目的是分享这些年自己积累的一些学习材料&#xff0c;方面大家查找使用&#xff0c;包括电子书、案例项目、学习视频、面试题和一些PPT模板。里面所有材料都免费分享。目前小程序中只发…

@Qualifier的用处

Qualifier的用处 可以对于一个接口&#xff0c;多个实现类&#xff0c;指定具体注入哪个实现类到这个接口类 在Server 实例化的时候没有指明名称&#xff0c;在atuoWire的时候没有用Quality指明用哪一个的时候&#xff0c;这这时会用容器中仅有的那一个对象&#xff08;单利&am…

@Autowired和@Qualifier

Autowired 的作用是什么&#xff1f; 1、Autowired 是一个注释&#xff0c;它可以对类成员变量、方法及构造函数进行标注&#xff0c;让 spring 完成 bean 自动装配的工作。 Autowired 默认是按照类去匹配&#xff0c;配合 Qualifier 指定按照名称去装配 bean。 可以这样理解为…

spring注解@Qualifier的详细用法

环境&#xff1a;springboot2.3.10 一般使用在项目中使用Qualifier来限定注入的Bean。 由于项目中我习惯用Resource注解&#xff0c;所以这里先对Autowired和Resource进行个简单的说明。 Autowired和Resource区别 相同点&#xff1a; Autowired与Resource都可以用来装配Be…

Spring 注解 @Qualifier 详细解析

文章目录 1. 概述2. 痛点3. Qualifier4. Qualifier VS Primary5. 通过名称来自动注入6. 总结 1. 概述 今天带你了解一下 Spring 框架中的 Qualifier 注解&#xff0c;它解决了哪些问题&#xff0c;以及如何使用它。我们还将了解它与 Primary 注解的不同之处。更多的技术解析请…

@Qualifier注解作用

Qualifier 注解作用就是为了给Bean打上一个标记&#xff0c;用来查找bean&#xff0c;代码示例: 创建一个java bean package com.gupaoedu.springcloud.example.demo;public class TestClass {private String name; // getter setter 略 }编写配置类&#xff0c;将这个bean装载…