海森矩阵和半正定矩阵

多元函数的Hessian矩阵就类似一元函数的二阶导。

多元函数Hessian矩阵半正定就相当于一元函数二阶导非负,半负定就相当于一元函数二阶导非正。如果这个类比成立的话,凸函数的Hessian恒半正定就非常容易理解了——这是一元凸函数二阶导必非负的多元拓展。

至于为什么这个类是有道理的,你要这么看。对一元函数f(x)来说,就极值而言,一阶导为0是极值点的必要但不充分条件,一阶导为0切二阶导非负是极小值的充要条件。

为什么呢,因为有泰勒展开f(x)=f(x_0)+f'(x_0)cdot	ext{d}x+frac{1}{2}f''(x_0)	ext{d}x^2。如果一阶导为0,二阶导非负,dx不论是多少,f(x)一定不比f(x0)小。

你把多元函数也个泰勒展开,主要区别在于:
1) 二阶导变成了Hessian。
2) 以前只要考虑x怎么变,现在还要考虑y怎么变,x和y怎么一起变,头疼了很多。
以二元为例,
f(egin{bmatrix}x & yend{bmatrix}) = 
f(egin{bmatrix}x_0 & y_0end{bmatrix}) + 
egin{bmatrix}	ext{d}x & 	ext{d}yend{bmatrix} cdot egin{bmatrix}f_x' \ f_y' end{bmatrix}
+ frac{1}{2} egin{bmatrix}	ext{d}x & 	ext{d}yend{bmatrix} cdot egin{bmatrix}f_{xx}' & f_{xy}' \ f_{yx}' & f_{yy}' end{bmatrix} cdot egin{bmatrix}	ext{d}x \ 	ext{d}yend{bmatrix}
从一元的情况类比过来,如果一阶导为0,是不是极小值完全取决于不同的dx, dy下,能不能做到最后一项一直非负。

只有对于任意Delta {f x},Delta {f x} {f H} Delta {f x}^T 一直非负的情况,我们才能说这是极小值。如果Delta {f x} {f H} Delta {f x}^T一直非正,这就是极大值。如果它一会正一会负,就是鞍点。

然后“对于任意Delta {f x},Delta {f x} {f H} Delta {f x}^T 一直非负”这是啥?半正定的定义嘛!它就是这么引出来的,也是我们为什么需要半正定这个概念的原因



我们首先假设
  • 函数在定义域上连续
  • 函数在定义域上二阶可导

现在要证明的是:
  1. definition  Rightarrow 1st-order condition
  2. 1st-order condition  Rightarrow 2nd-order condition

实际上这些都是充要关系,但是因为题主的问题并没有要求证明必要性我这里就偷懒只证明充分性了。

首先凸函数(一元)的定义是:
任意属于定义域的两个自变量x_1x_2,且对于任意[0 le 	heta  le 1],如果函数fleft(  cdot  
ight)满足fleft( {	heta {x_1} + left( {1 - 	heta } 
ight){x_2}} 
ight) le 	heta fleft( {{x_1}} 
ight) + left( {1 - 	heta } 
ight)fleft( {{x_2}} 
ight),那么函数fleft(  cdot  
ight)是凸函数。

直观的理解就是函数曲线上任意两点为短点的线段一定在函数曲线的上方。
多变量函数可以把自变量写成一个向量{f{x}} = {left[ {{x_1},{x_2}, ldots ,{x_n}} 
ight]}^T,同理对于定义域的任意两个自变量{f{x}}_1{f{x}}_2,以及任意0 le 	heta  le 1,如果函数fleft(  cdot  
ight)满足fleft( {	heta {f{x_1}} + left( {1 - 	heta } 
ight){f{x_2}}} 
ight) le 	heta fleft( {f{{x_1}}} 
ight) + left( {1 - 	heta } 
ight)fleft( {f{x_2}} 
ight),那么函数fleft(  cdot  
ight)是凸函数。

1st-order condition 一阶条件,还是以一元函数为例:
对于定义域内任意两个自变量x_1x_2,函数fleft(  cdot  
ight)满足则函fleft( {{x_2}} 
ight) ge fleft( {{x_1}} 
ight) + f'left( {{x_1}} 
ight)left( {{x_2} - {x_1}} 
ight)fleft(  cdot  
ight)为凸函数。

直观的理解就是函数曲线始终位于任意一点的切线的上方。类似于前面
提到的二阶Taylor展开中必须保证二次项非负。推广到多变量函数同理可以写为fleft( {{{f{x}}_1}} 
ight) ge fleft( {{{f{x}}_2}} 
ight) + 
abla fleft( {{{f{x}}_2}} 
ight) cdot left( {{{f{x}}_1} - {{f{x}}_2}} 
ight),其中梯度向量
abla fleft( {f{x}} 
ight) = left( {frac{{partial fleft( {f{x}} 
ight)}}{{partial {x_1}}},frac{{partial fleft( {f{x}} 
ight)}}{{partial {x_2}}}, ldots ,frac{{partial fleft( {f{x}} 
ight)}}{{partial {x_n}}}} 
ight)也就是在该点对各个变量求偏导构成的向量。

现在要证明的凸函数有fleft( {{x_2}} 
ight) ge fleft( {{x_1}} 
ight) + f'left( {{x_1}} 
ight)left( {{x_2} - {x_1}} 
ight)的性质。

假设函数fleft(  cdot  
ight)在定义域上是凸函数,那么有:
egin{align}
fleft( {	heta {{f{x}}_1} + left( {1 - 	heta } 
ight){{f{x}}_2}} 
ight) & le 	heta fleft( {{{f{x}}_1}} 
ight) + left( {1 - 	heta } 
ight)fleft( {{{f{x}}_2}} 
ight) \
fleft( {{{f{x}}_2} + 	heta left( {{{f{x}}_1} - {{f{x}}_2}} 
ight)} 
ight) &le fleft( {{{f{x}}_2}} 
ight) + 	heta left( {fleft( {{{f{x}}_1}} 
ight) - fleft( {{{f{x}}_2}} 
ight)} 
ight) \
fleft( {{{f{x}}_2} + 	heta left( {{{f{x}}_1} - {{f{x}}_2}} 
ight)} 
ight) - fleft( {{{f{x}}_2}} 
ight) &le 	heta left( {fleft( {{{f{x}}_1}} 
ight) - fleft( {{{f{x}}_2}} 
ight)} 
ight) \
frac{{fleft( {{{f{x}}_2} + 	heta left( {{{f{x}}_1} - {{f{x}}_2}} 
ight)} 
ight) - fleft( {{{f{x}}_2}} 
ight)}}{	heta } &le fleft( {{{f{x}}_1}} 
ight) - fleft( {{{f{x}}_2}} 
ight)
end{align}
然后稍微变形可以得到fleft( {{{f{x}}_1}} 
ight) ge fleft( {{{f{x}}_2}} 
ight) + frac{{fleft( {{{f{x}}_2} + 	heta left( {{{f{x}}_1} - {{f{x}}_2}} 
ight)} 
ight) - fleft( {{{f{x}}_2}} 
ight)}}{	heta }
gleft( 	heta  
ight) = fleft( {{{f{x}}_2} + 	heta left( {{{f{x}}_1} - {{f{x}}_2}} 
ight)} 
ight),则gleft( 0 
ight) = fleft( {{{f{x}}_2}} 
ight),那么有
fleft( {{{f{x}}_1}} 
ight) ge fleft( {{{f{x}}_2}} 
ight) + frac{{gleft( 	heta  
ight) - gleft( 0 
ight)}}{	heta },当	heta趋近于0时,有mathop {lim }limits_{	heta  	o 0} frac{{gleft( 	heta  
ight) - gleft( 0 
ight)}}{	heta } = g'(0)这一项也就是函数{gleft( 	heta  
ight)}	heta=0处的导数值,[{gleft( 	heta  
ight)}]实际是[fleft( {{{f{x}}}} 
ight)]{f{x}} = {{f{x}}_2} + 	heta left( {{{f{x}}_1} - {{f{x}}_2}} 
ight)的复合函数,容易求导得frac{{dg}}{{d	heta }} = left( {{{f{x}}_1} - {{f{x}}_2}} 
ight)frac{{dfleft( {{{f{x}}_2} + 	heta left( {{{f{x}}_1} - {{f{x}}_2}} 
ight)} 
ight)}}{{d{f{x}}}},由于只要求在	heta=0处的导数值所以容易得{left. {frac{{dg}}{{d	heta }}} 
ight|_{	heta  = 0}} = left( {{{f{x}}_1} - {{f{x}}_2}} 
ight)frac{{dfleft( {{{f{x}}_2}} 
ight)}}{{d{f{x}}}} = 
abla fleft( {{{f{x}}_2}} 
ight) cdot left( {{{f{x}}_1} - {{f{x}}_2}} 
ight),代入回不等式即可得到
fleft( {{{f{x}}_1}} 
ight) ge fleft( {{{f{x}}_2}} 
ight) + 
abla fleft( {{{f{x}}_2}} 
ight) cdot left( {{{f{x}}_1} - {{f{x}}_2}} 
ight)

从图形上也可以直观去理解这个推导结果,取函数曲线上两点作直线,被函数图像截断的那部分始终在曲线上方,而其他部分始终在曲线下方,那么这两个点取的无限接近,也就是通常我们说的“割线逼近切线”,那么切线就始终在曲线下方了,曲线不知道高到哪里去了。

现在我们来做第二部分也就是用1st-order condition推导2nd-order condition的部分的证明了。

2nd-order condition的内容就是凸函数的Hessian矩阵半正定。多元Taylor展开如果不熟悉的话可以参考Taylor's theorem的公式自己理解,我这里就不详细展开了,直接写在f{x_0}点处二阶展开形式:
fleft( {f{x}} 
ight) = fleft( {{{f{x}}_0}} 
ight) + 
abla fleft( {{{f{x}}_0}} 
ight)left( {{f{x}} - {{f{x}}_0}} 
ight) + frac{1}{2}{left( {{f{x}} - {{f{x}}_0}} 
ight)^T}{f{H}}left( {{f{x}} - {{f{x}}_0}} 
ight),这里的f{H}f(f{x})f{x_0}点处的Hessian矩阵,也可以写作{
abla ^2}fleft( {f{x}_0} 
ight)可以理解为把梯度向量推广为二阶形式,梯度向量本身也是Jacobian矩阵的一种特例。
f(f{x})的Hessian矩阵第i行第j个元素为f(f{x})对第i个变量先求导,对第j个变量后求导的二阶导数,也就是{{f{H}}_{ij}} = frac{{{partial ^2}fleft( {f{x}} 
ight)}}{{partial {x_i}partial {x_j}}},写成矩阵形式就是:
[{f{H}} = left[ {egin{array}{*{20}{c}}
{frac{{{partial ^2}fleft( {f{x}} 
ight)}}{{partial x_1^2}}}&{frac{{{partial ^2}fleft( {f{x}} 
ight)}}{{partial {x_1}partial {x_2}}}}& cdots &{frac{{{partial ^2}fleft( {f{x}} 
ight)}}{{partial {x_1}partial {x_n}}}}\
{frac{{{partial ^2}fleft( {f{x}} 
ight)}}{{partial {x_2}partial {x_1}}}}&{frac{{{partial ^2}fleft( {f{x}} 
ight)}}{{partial x_2^2}}}& cdots &{frac{{{partial ^2}fleft( {f{x}} 
ight)}}{{partial {x_2}partial {x_n}}}}\
 vdots & vdots & ddots & vdots \
{frac{{{partial ^2}fleft( {f{x}} 
ight)}}{{partial {x_n}partial {x_1}}}}&{frac{{{partial ^2}fleft( {f{x}} 
ight)}}{{partial {x_n}partial {x_2}}}}& ldots &{frac{{{partial ^2}fleft( {f{x}} 
ight)}}{{partial x_2^2}}}
end{array}} 
ight]]
回到上面那个Taylor展开式,对于一个凸函数,我们可以试用1st-order condition得到fleft( {f{x}} 
ight) ge fleft( {{{f{x}}_0}} 
ight) + 
abla fleft( {{{f{x}}_0}} 
ight)left( {{f{x}} - {{f{x}}_0}} 
ight)对于任意的f{x}{{{f{x}}_0}}都成立,那么二次项frac{1}{2}{left( {{f{x}} - {{f{x}}_0}} 
ight)^T}{f{H}}left( {{f{x}} - {{f{x}}_0}} 
ight) ge 0必须对于任意的两个自变量f{x}{{{f{x}}_0}}恒成立,我们这里以增量简写Delta {f{x}} = {f{x}} - {{f{x}}_0},这个增量可以任意取值,那么需要Delta {{f{x}}^T}{f{H}}Delta {f{x}} ge 0对于任意一个Delta {f{x}}恒成立,而这就是f{H}是半正定的充要条件。



原文地址:https://www.cnblogs.com/wqbin/p/10562160.html