1 Truncated Normal
在初始化模型的weight的时候,通常使用 truncated_normal.
tf.truncated_normal(
shape,
mean=0.0,
stddev=1.0,
dtype=tf.float32,
seed=None,
name=None
)
tf中的介绍是:
The generated values follow a normal distribution with specified mean and standard deviation, except that values whose magnitude is more than 2 standard deviations from the mean are dropped and re-picked.
也就是两倍标准差之外的生成值都被移除,重新生成,保证所有生成数据都在标准差两倍之内。
2 Activation function ReLU
首先来看一下Sigmoid及其导数形式
f(x)=sigmoid(x)=
11+e−x
1
1
+
e
−
x
f’(x)=f(x)*(1-f(x))
Sigmoid的导数始终小于1,其最大值是0.25,如果有很多层网络,这些导数在相乘之后,值会迅速接近0,也就是梯度消失现象。
再来看看ReLU的形式。
Rectified linear unit:
f(x)=max(0,x)
f
(
x
)
=
m
a
x
(
0
,
x
)
这个激励函数看起来形式简单,但实际中效果比sigmoid和tanh效果都要好。
主要原因有两个:
第一,ReLU降低梯度消失现象额可能性,这是因为,在x>0的时候,梯度是一个常数,常数梯度也使得学习更快。
第二,ReLU的稀疏性,当x<0时,信号不会被激活。也就保证了部分节点是处于抑制状态。