前几篇侃了侃SVM的基本原理和一些相关知识,尤其是在SVM学习——软间隔优化这一篇,提到了SVM学习器的两种形式,常被叫做L1-SVM和L2-SVM,这两种形式的区别在损失函数的形式上,令训练样例为SVM学习——Coordinate Desent MethodSVM学习——Coordinate Desent Method取值为-1或+1,

软间隔优化的原始形式为:

                                           SVM学习——Coordinate Desent Method

当损失函数SVM学习——Coordinate Desent MethodSVM学习——Coordinate Desent Method时就叫做L1-SVM,当损失函数SVM学习——Coordinate Desent MethodSVM学习——Coordinate Desent Method 时叫做L2-SVM,实际当中解这个问题其实可以从原始形式开始,也可以从其对偶形式开始:

SVM学习——Coordinate Desent MethodSVM学习——Coordinate Desent Method,则两种软间隔优化的对偶形式可以用统一的形式表示:

                                           SVM学习——Coordinate Desent Method  

                                              SVM学习——Coordinate Desent Method                        其中:SVM学习——Coordinate Desent Method为单位列向量,SVM学习——Coordinate Desent MethodSVM学习——Coordinate Desent MethodSVM学习——Coordinate Desent Method为对角矩阵

对于L1-SVM:SVM学习——Coordinate Desent Method && SVM学习——Coordinate Desent Method;对于L2-SVM:SVM学习——Coordinate Desent Method && SVM学习——Coordinate Desent Method

       不管哪种形式,都是一个凸二次规划问题,不论是向量维度大或者是样本量很大的时候,求解这个优化问题难度都不小,于是在解得稀疏性(比如只需要得到支持向量)、目标函数的凸性等方面动脑筋,得到一些较有效率的方法,比如SMO(Sequential Minimal Opimisation)、梯度下降法、Trust Region Newton Method、Coordinate Desent Method 等等,这里面呢,我对Coordinate Desent Method 比较感兴趣,我就把我学到的东西说一下。

      先了解几个概念:

1、度量空间:它是一个集合,在其中可以定义这个集合中元素之间的距离(叫做度量)的概念,这个距离满足非负性、同一性、对称性以及三角不等式(类似于咱们小时候学的,任意三角形,两边之和大于第三边),见http://zh.wikipedia.org/zh-cn/%E5%BA%A6%E9%87%8F%E7%A9%BA%E9%97%B4

2、Lipschitz 函数:对于一个实值函数SVM学习——Coordinate Desent Method以及定义在实数域(实数域包含有理数和无理数而且它是完备的)上的集合SVM学习——Coordinate Desent Method,如果存在常数L>0,使得SVM学习——Coordinate Desent Method,则这个函数叫做Lipschitz 函数(这里用2-范数来度量集合SVM学习——Coordinate Desent Method中两个向量SVM学习——Coordinate Desent MethodSVM学习——Coordinate Desent Method的距离),它的几何意义其实就是:曲线上的任意两点的连线的斜率都有一个相同的上界,见http://zh.wikipedia.org/zh-cn/%E5%88%A9%E6%99%AE%E5%B8%8C%E8%8C%A8%E9%80%A3%E7%BA%8C

       直观的看满足Lipschitz 条件条件的函数一定是连续函数,而且曲线更加光滑,反之不然,比如在[0,1]上的函数SVM学习——Coordinate Desent Method,显然它不满足Lipschitz 条件。

SVM学习——Coordinate Desent Method

定理1:如果定义在实数域上的集合SVM学习——Coordinate Desent Method是一个凸集,实值函数SVM学习——Coordinate Desent Method连续可微且在SVM学习——Coordinate Desent Method内其梯度有界,则SVM学习——Coordinate Desent Method

偶简单推导一下:

       SVM学习——Coordinate Desent Method是一个凸集,那么根据凸集定义:对于凸集中的任意向量SVM学习——Coordinate Desent MethodSVM学习——Coordinate Desent Method(不是一般性,假设SVM学习——Coordinate Desent Method),有SVM学习——Coordinate Desent Method,其中SVM学习——Coordinate Desent Method。显然SVM学习——Coordinate Desent Method在[SVM学习——Coordinate Desent Method,SVM学习——Coordinate Desent Method]上连续,在(SVM学习——Coordinate Desent Method,SVM学习——Coordinate Desent Method)内可导,而SVM学习——Coordinate Desent MethodSVM学习——Coordinate Desent MethodSVM学习——Coordinate Desent Method之间,根据拉格朗日中值定理有,SVM学习——Coordinate Desent Method,其中SVM学习——Coordinate Desent MethodSVM学习——Coordinate Desent Method,显然SVM学习——Coordinate Desent Method

       之所介绍Lipschitz 条件是因为,如果可微函数SVM学习——Coordinate Desent Method梯度满足Lipschitz连续条件,即:SVM学习——Coordinate Desent Method,则有:

                                                SVM学习——Coordinate Desent Method (证明过程比较直白,偶就不写了,只要把f展开成二阶泰勒级数,然后代入Lipschitz连续条件得证)

基于梯度下降(GD)的算法应该是最为大家所熟知的一类算法(最速下降法、牛顿法、阻尼牛顿法、拟牛顿法等等),我把满足上述条件的不等式换成另一种写法吧:

                                      SVM学习——Coordinate Desent Method

对于最小化问题,总是希望每次迭代都可以让SVM学习——Coordinate Desent Method,这样我们会越来越接近目标,对于上式的右边部分用函数SVM学习——Coordinate Desent Method代替,可以很容易知道,在SVM学习——Coordinate Desent Method点,SVM学习——Coordinate Desent Method取到极小值(嘿嘿,比如求导),于是,梯度下降算法可以被概括为:

GD Algorithm

                     1、选择初始点SVM学习——Coordinate Desent Method,令SVM学习——Coordinate Desent Method

                     2、SVM学习——Coordinate Desent Method(不满足结束条件){

                                  SVM学习——Coordinate Desent Method;       //这里的S是个保序操作符(SVM学习——Coordinate Desent Method是保序操作符,指如果SVM学习——Coordinate Desent Method,则有SVM学习——Coordinate Desent Method

                                  SVM学习——Coordinate Desent Method

                            }

        与GD较为不同的另一类算法就叫做Coordinate Desent Method,这种方法的特点是,算法有两层迭代,最内层迭代是一个搜索过程,搜索是依据n维向量的n个坐标方向分别搜索,每次迭代会将除了当前方向外的其他方向分量固定,然后在此基础上最小化目标函数,下次迭代时会选择另外一个分量进行相同的处理,经过了n次迭代后得到一个n维向量,然后更新目标向量,接着继续进行外层的迭代,概括这个过程如下:

CD Algorithm

                      1、选择初始点SVM学习——Coordinate Desent Method,令SVM学习——Coordinate Desent Method

                      2、SVM学习——Coordinate Desent Method(不满足结束条件){

                                   SVM学习——Coordinate Desent Method

                                   SVM学习——Coordinate Desent Method{                               //假设特征空间维度为SVM学习——Coordinate Desent Method

                                         SVM学习——Coordinate Desent Method;     //这里的S是个操作符

                                         SVM学习——Coordinate Desent Method;  (SVM学习——Coordinate Desent Method

                                    }

                                    SVM学习——Coordinate Desent Method;

                                    SVM学习——Coordinate Desent Method

                              }

     还记着开篇提到的L1-SVM和L2-SVM的统一形式吧,稍微转换一下形式,并把SVM学习——Coordinate Desent Method扩展为SVM学习——Coordinate Desent Method,把SVM学习——Coordinate Desent Method扩展为SVM学习——Coordinate Desent Method

                                           SVM学习——Coordinate Desent Method

                                           SVM学习——Coordinate Desent Method                        其中:SVM学习——Coordinate Desent Method为单位列向量,SVM学习——Coordinate Desent MethodSVM学习——Coordinate Desent MethodSVM学习——Coordinate Desent Method为对角矩阵

对于L1-SVM:SVM学习——Coordinate Desent Method && SVM学习——Coordinate Desent Method;对于L2-SVM:SVM学习——Coordinate Desent Method && SVM学习——Coordinate Desent Method

       下面介绍一种基于Coordinate Descent 的算法,该算法出自《A Dual Coordinate Descent Method for Large-scale Linear SVM》一文。

整个算法架构同CD Algorithm

1、假设样本数为SVM学习——Coordinate Desent Method,当前外层循环的索引为SVM学习——Coordinate Desent Method,当前内层循环索引为SVM学习——Coordinate Desent Method,其取值为SVM学习——Coordinate Desent Method,对于SVM学习——Coordinate Desent Method向量有表示形式:

                                          SVM学习——Coordinate Desent MethodSVM学习——Coordinate Desent Method

SVM学习——Coordinate Desent Method,表示还没有开始内层循环时的状态,SVM学习——Coordinate Desent Method,表示对所有分量更新完毕。

2、内层循环中的S操作的过程是求解子问题:

                                          SVM学习——Coordinate Desent Method

                                            SVM学习——Coordinate Desent Method,其中SVM学习——Coordinate Desent Method,第SVM学习——Coordinate Desent Method个分量的值为1。

大家可以在纸上稍作推导,上面这个问题的目标函数可以表示为:

                                         SVM学习——Coordinate Desent Method ,其中SVM学习——Coordinate Desent Method表示梯度SVM学习——Coordinate Desent Method的第SVM学习——Coordinate Desent Method个分量

这是一个二次函数,除了带d的部分以外可以看做一个常量,即上述形式为:

                                         SVM学习——Coordinate Desent Method

SVM学习——Coordinate Desent Method

       1)、当SVM学习——Coordinate Desent Method时不需要对当前分量进行更新;

       2)、对上式求K-T点并考虑SVM学习——Coordinate Desent Method约束条件,如果SVM学习——Coordinate Desent Method则有:

                                        SVM学习——Coordinate Desent Method

计算SVM学习——Coordinate Desent Method,就是将核矩阵的第SVM学习——Coordinate Desent Method行向量和SVM学习——Coordinate Desent Method向量做内积,这个操作代价很高,但是对于线性SVM,有SVM学习——Coordinate Desent Method(还记得那个互补条件吧,嘿嘿),又有SVM学习——Coordinate Desent MethodSVM学习——Coordinate Desent Method,于是上式就变成了SVM学习——Coordinate Desent Method,这个计算的代价就没有那么高了,显然在更新SVM学习——Coordinate Desent Method的时候需要对SVM学习——Coordinate Desent Method也更新,要是每次都计算SVM学习——Coordinate Desent Method就代价太高了,所以文中利用SVM学习——Coordinate Desent Method更新前和更新后的值来确定SVM学习——Coordinate Desent Method,如下:

                                        SVM学习——Coordinate Desent Method (这个方法很巧)

          3)、当SVM学习——Coordinate Desent Method时候,可知SVM学习——Coordinate Desent Method,这种情况只会出现在L1_SVM中,且此时没有阈值项,就是那个SVM学习——Coordinate Desent Method向量里的分量1,否则SVM学习——Coordinate Desent Method不可能满足,此时新的SVM学习——Coordinate Desent Method分量值就取SVM学习——Coordinate Desent Method

A dual coordinate descent method for Linear SVM算法描述如下:

                      1、选择初始点SVM学习——Coordinate Desent Method

                           令SVM学习——Coordinate Desent Method

                               SVM学习——Coordinate Desent Method

                      2、SVM学习——Coordinate Desent Method(不满足结束条件,这里可以设置一个精度条件){

                                   SVM学习——Coordinate Desent Method{                             

                                       SVM学习——Coordinate Desent Method

                                       SVM学习——Coordinate Desent Method

                                                 SVM学习——Coordinate Desent Method{

                                                         SVM学习——Coordinate Desent Method

                                                         SVM学习——Coordinate Desent Method

                                                         SVM学习——Coordinate Desent Method

                                                 }

                                    }

                                    SVM学习——Coordinate Desent Method;

                                    SVM学习——Coordinate Desent Method

                              }

         与GD方法相比,coordinate descent 类方法的特点是每次迭代的代价较低,由于SVM学习——Coordinate Desent Method各分量之间有前后依赖关系,所以感觉要实现并行有点困难, 但是总的来说,没有最好的方法只有最适合的方法。

相关文章: