NIPS-2015(ResNet的前世)
高速网络(Highway net)和残差网络(Residual Network)各有什么优劣?
借鉴知乎中的一个回答 https://www.zhihu.com/search?type=content&q=highway
“个人理解,你可以把二者都看作用一个通用指令集来完成一个程序,highway的指令集比ResNet的要大,所以前者比后者灵活度更高,但是复杂度也增加了。”
文章目录
1 Background and Motivation
深度学习崭露头角,在传统的 ML 中有不错的突破,In fact, deep networks can represent certain function classes far more efficiently than shallow ones(作者给了一些证据). 然而,It’s difficult to train deep networks.
To overcome this,学者们进行了积极的探索
- optimizers
- well-designed initialization
- activation function based on local competition(maxout)
- skip connection
- soft target
- trained layer-wise(这个方法不太懂)
作者 inspiration from LSTM,提出了 Hightway network(门机制),来缓解这个难题!
2 Advantages
借鉴了LSTM的长期短期记忆的门机制的一些思想,使得网络在很深都可以学习,形成了 information route,让网络根据不同的问题复杂度,利用不同的 layer 来处理 !
3 Innovations
提出了一种解决 deep network 难训练的方法,让 network 上高速公路
4 Highway Networks
1)notation
boldface letters(黑体)表示 vectors and matrices
italicized capital letters(斜体大写字母)表示 transformation function
2)highway network
-
plain feed forward neural network(公式1)
H:non-linear transformation -
Highway network(公式2)
·:element-wise multiply
T:transform gate
C:carry gate
since they express how much of the output is produced by transforming the input and carrying it, respectively.
通俗的说是,有多少作用在输入(x)上(C),有多少作用在输入的转化(H)上(T),T 和 C 是 adaptive gating units,LSTM 中的门机制,把两个卷积的结果相乘,参考 【Keras-LSTM】IMDb! -
Highway network(For simplicity,公式3)
particular values(公式4)
求导(公式5)
哈哈哈,太熟悉了,看过 ResNet 之后,再看这个,就发现,ResNet 落地的太完美了!
3)Constructing Highway Networks
公式3 可以看出,
x
x
x,
y
y
y,
H
(
x
,
W
H
)
H(x,W_H)
H(x,WH),
T
(
x
,
W
T
)
T(x,W_T)
T(x,WT) 的 dimension 必须一样(因为 · 是 element-wise multiply)
若不一样,如下方式可供选择
x
→
x
^
x \to \hat{x}
x→x^
- sub-sampling(变小)
- zero-padding(变大)
- plain layer(without highways)(可小可大)
后面两种方法正是 resnet 中 feature map 的 resolution 下降时,采用的 shortcut 方式!
作者 H 和 T 设计中,用的 the same sized receptive fields(一样的 filters size)
4)Training Deep Highway Networks
b
T
b_T
bT 设置为 a negative value,such that the network is initially biased towards carry behavior.(shortcut 的那条分支)
这里的
σ
\sigma
σ 为 sigmoid,也即
σ
(
x
)
=
1
1
+
e
−
x
\sigma(x) = \frac{1}{1 + e^{-x}}
σ(x)=1+e−x1
所以 particular values(公式4)永远不会满足
5)highway network
一层有很多 blocks,a highway network consists of multiple blocks such that the
i
t
h
i^{th}
ith block computes a block state
H
i
(
x
)
H_{i}(x)
Hi(x) and transform gate output
T
i
(
x
)
T_{i}(x)
Ti(x)
Finally, it produces the block output
which is connected to the next layer
5 Experiments
关于 Fitnet 可以参考 论文笔记 《FitNets- Hints for Thin Deep Nets》
motivation 如下:既然网络很深直接训练会困难,那就通过在中间层加入loss的方法,如此分成两块来训练,应该能得到更好的结果。至于中间的loss怎么来?自然就是通过teacher network的中间feature map来得到的。paper中把这个方法叫做 Hint-based Training (HT)
图中
W
r
W_r
Wr是为了让 student 的 feature map 和 teacher 的feature map相同
- 通过 HT(Hints Training) 来训练前半层
- 通过 KD (knowledge distilling)来训练整个网络
最后的效果居然比 teacher 网络还要好,非常吃惊
5.1 Optimization
纵坐标 Training Set Cross Entropy Error,右侧的图直观多了,结论如下
- highway networks do not suffer from increasing depth
- highway consistently converged significantly faster than plain ones
5.2 Pilot Experiments on MNIST Digit Classification
width 表示 blocks 的数量,精度和 state-of-the-art 相仿,parameters 更少
5.3 Experiments on CIFAR-10 and CIFAR-100
1)vs Fitnet A
2)vs state-of-the-art
5.4 Analysis
5.4.1 Visualization T 、b and y
50层,The first hidden layer is a plain layer which changes the dimensionality of the representation to 50.
后面 49 层都是 每层 50个 blocks,第二列是所有 training set 的 T 的均值,第三列和第四列的单个样本的 T 和 y!
y = H ( x , W H ) ⋅ T ( x , W T ) + x ⋅ ( 1 − T ( x , W T ) ) y = H(x,W_H) \cdot T(x,W_T) + x \cdot (1-T(x,W_T)) y=H(x,WH)⋅T(x,WT)+x⋅(1−T(x,WT))
T = σ ( W T T x + b T ) T = \sigma(W_T^Tx+b_T) T=σ(WTTx+bT)
MNIST bias 初始化为 -2,CIFAR 10 bias 初始化为 -4,随着层数增加,
b
T
b_T
bT 在增加,
T
T
T 值在减小,This indicates that the strong negative biases at low depths are not used to shut down the gates, but to
make them more selective.(初始化 bias 为负值,并不会使门关闭,更有利于选择)
最后一列,y 的输出在许多层比较稳定,Most of the outputs stay constant over many layers forming a pattern of stripes.
改变在后面的层比较少 Most of the change in outputs happens in the early layers (≈ 15 for MNIST and ≈ 40 for CIFAR-100).
我们从 T 的输出变化可以看出,网络越深,越依赖于是走 shortcut 这条路,从 y 的输出变化可以看出, H 和 x 两条路占比虽然随着网络深度在变化,但是总和维持在一定的值!
上面的分析,也在作者的 “the network can learn to dynamically adjust the routing of the information based on the current input.” 这句话中得到了证实!
是动态路由(Routing of Information)还是静态路由呢?does this behaviour manifest itself in trained networks or do they just learn a static routing that applies to all inputs similarly.
也就是 H 和 x 的门(T 和 1-T)对每个样本是变动的还是固定的?
通过上图的 2-3 列我们可以看出,mean T (所有样本)与 T(单个样本) 差别还是挺大的,说明在动态信息路由!
作者把他称为 data-dependent routing mechanism
5.4.2 data-dependent routing mechanism
不同类别的 mean T 去比较,发现差别还是存在的(MNIST 的差距集中在前 15 layers,CIFAR-10分布在所有层之中),进一步说明,是动态的信息路由,也即门的值是依赖数据的!
5.4.3 Layer Importance
y = HT + x(1-T)
lesioning(机能障碍,这里指的把T置为0,也即网路层自身的叠加)
注意,正常的 highway training error 在虚线以下!!!
- MNIST 15-45 layers,直接等变映射(lesioning),结果也不差,作者的解释为MNIST 数据集太简单,不用太深
- CIFAR-10 则不一样,前40下降的还是比较明显的,说明 highway 对于复杂的问题,可以学会利用它的所有层!(也即网络能根据问题的规模,学会利用不同的层,再通俗点,也就是让信息在每层多了条选择的路罢了)
从 CIFAR-10 可以看出网络的越深处越依赖于等变映射,也即 T = 0,所以 lesioning 之后的结果随着 layers 增加,越接近(no lesioning)
A possible objection is that many layers might remain unused if the transform gates stay closed.(从MNIST 的15-45 layers 可以窥探出端倪)
图 4 的这种实验方式,还可以知道不同的问题规模需要多深的网络,这是 plain network 做不到的!
6 小节
实验方式挺好的,可以思考下下面的问题!
- 每个 block 中的 x 是整个特征图吗?
- initially bias 为负数,网络更倾向于 shutcut 很好理解,但是为什么需要这么样初始化呢?(知乎的一篇文章有句话写的特别好 “ 这说明浅层的 strong negtive bias 是让更多的信息直接 pass,使得深层网络可以更多的进行处理。” 来自 Paper阅读笔记《Highway Networks》-神经网络上高速不是梦)
- 论文一开始举例 n bit parity problem,证明 depth is better than shallow,这个需要了解一波
【论文笔记】Training Very Deep Networks - Highway Networks 总结的非常形象。
- 像高速公路,多数车在一个车道行驶,偶尔变道
- 那么这种“变道”是固定的吗?答案是不对,数据还是会选择合适地方进行变道(图3)
- 另一个问题,既然真正激活的内容那么少,是不是意味着许多层并没有提供贡献?答案:要看问题规模(图4)