各位看官请注意,本文主要依据《神经网络设计(Neural Network Design)》撰写,想阅读原文请移步Neural Network Design,想继续啃方便面,请继续往下看。
当神经网络结构(神经元多少、层数、连接方式、激活函数)确定之后,对其训练和学习就是对
F(w)
(performance function、cost function、energy function,之间的区别与联系可以看lecun的一篇文章,在这里称作性能函数)的优化问题。也就是寻找一组合适的链接权
w
,使得性能函数取得最小值。一般的神经网络方法都是迭代的方法,给定一个
或者
其中, pk 表示搜索方向; αk 是学习因子,决定更新的步长。
因此呢,所谓的学习方法,也就是去计算 pk 和 αk 。我们首先介绍一些计算 pk 和 αk 的方法,然后将其结合Backpropagation算法,将其应用到神经网络的学习中去。
performance optimization
对于
F(w)
的优化是基于泰勒展式(Taylor Series Expansion):
于是乎就出现先了一阶、二阶优化方法(为什么没有三阶、四阶呢?关键是性能函数 F(w) 的三阶、四阶导数存在嘛、好求吗?比如说常用的欧式距离,三阶导数是0呢。。。即使存在,二阶导数已经累死人了,三阶导数你敢求吗?实际应用的神经网络的连接数随随便便都已经数以万计了吧)
首先咱们说说一阶方法。
根据泰勒展式
记 ∇F(w)T|w=wk 为 gTk ,其实 gk 也就是梯度。要使得 F(wk+1)<F(wk) ,故而 gTkαkpk<0 。又因为 αk>0 ,所以
那么任何满足上式的 pk 都可以作为搜索方向,乘以一个足够小的 αk 都可以使得性能函数变小。为了加快收敛速度,自然是选择与 gk 反向作为 pk 的方向了。方便起见呢,就是
这就是传说中的梯度下降算法了。
另外一个需要解决的问题就是
αk
取多少合适?足够小,可以收敛,但是速度太慢了啊。太大又容易产生震荡,甚至直接就发散跑了。。。
那有没有一个范围可以指导一下呢?答案是有。(可以看看Lecun的这篇文章)其实,当
pk
选择之后,就变成了相对于
α
来优化
F(x)
。有很多搜索方法,来选择
αk
。以后再讨论。
现在说说这个二阶方法,也就是所谓的牛顿法,运气好的话,一步就得到解析解。
同样的根据泰勒展式
这个时候呢对 Δwk 求导,并等于零,我们就得到
那么我们得到 Δwk=−A−1gk
所以牛顿法就是 wk+1=wk−A−1gk .
一般来说呢,牛顿法比最速下降法快,但是呢 −A−1 不一定存在啊,存在了也不一定收敛啊。。。要命。。。。
那就有必要引入一个新的方法,也就是共轭梯度法。。
未完待续