zoukankan      html  css  js  c++  java
  • 基于高斯过程的贝叶斯优化(二)AC函数

    上节介绍过acquistion function(AC函数)是用来利用之前的信息寻找下一个$x_{t+1}$。下面介绍AC函数的具体形式:

    目前主流的AC函数主要有三种Probability of Improvement(PI),Excepted Improvement(EI),GP Upper Confidence Bound(GP-UCB)三种。

    首先介绍下最基本的数学背景。

    记$mathcal { D } _ { 1 : t } = left{ mathbf { x } _ { 1 : t } , f _ { 1 : t } ight}$为已经探索过得到的历史信息,其中$f_{t+1}=f(x_{t+1})$,假定我们所需搜寻的下一个值维$x_{t+1}$,且有$f_{t+1}=f(x_{t+1})$。记协方差矩阵K为:

    [mathbf { K } = left[ egin{array} { c c c } { k left( mathbf { x } _ { 1 } , mathbf { x } _ { 1 } ight) } & { dots } & { k left( mathbf { x } _ { 1 } , mathbf { x } _ { t } ight) } \ { vdots } & { ddots } & { vdots } \ { k left( mathbf { x } _ { t } , mathbf { x } _ { 1 } ight) } & { dots } & { k left( mathbf { x } _ { t } , mathbf { x } _ { t } ight) } end{array} ight]]

    根据高斯过程的性质,$f_{1:t}$与$f_{t+1}$服从联合高斯分布,这里假设其具有0均值:

    [left[ egin{array} { c } { mathbf { f } _ { 1 : t } } \ { f _ { t + 1 } } end{array} ight] sim mathcal { N } left( mathbf { 0 } , left[ egin{array} { c c } { mathbf { K } } & { mathbf { k } } \ { mathbf { k } ^ { T } } & { k left( mathbf { x } _ { t + 1 } , mathbf { x } _ { t + 1 } ight) } end{array} ight] ight)]

    这里有:

    [mathbf { k } = left[ k left( mathbf { x } _ { t + 1 } , mathbf { x } _ { 1 } ight) quad k left( mathbf { x } _ { t + 1 } , mathbf { x } _ { 2 } ight) quad cdots quad k left( mathbf { x } _ { t + 1 } , mathbf { x } _ { t } ight) ight]]

    通过求其边缘密度函数,可以得到:

    [ f _ { t + 1 } | mathcal { D } _ { 1 : t } , mathbf { x } _ { t + 1 } = mathcal { N } left( mu _ { t } left( mathbf { x } _ { t + 1 } ight) , sigma _ { t } ^ { 2 } left( mathbf { x } _ { t + 1 } ight) ight)]

    其中:

    [mu _ { t } left( mathbf { x } _ { t + 1 } ight) = mathbf { k } ^ { T } mathbf { K } ^ { - 1 } mathbf { f } _ { 1 : t }]

    [sigma _ { t } ^ { 2 } left( mathbf { x } _ { t + 1 } ight) = k left( mathbf { x } _ { t + 1 } , mathbf { x } _ { t + 1 } ight) - mathbf { k } ^ { T } mathbf { K } ^ { - 1 } mathbf { k }]

    (该推导可以参见Gaussian Processes for machine learning,Williams,2006 附录A2)

    有了上面的准备,就可以估计出$x_{t+1}$在任意取值处所服从的正态分布,从而可以设定特定的目标函数去定位下一步最优的$x_{t+1}$

    Probability of Improvement(PI)

    PI的思想在于基于最大可能概率改进,即假设当前已有的最优采样为$x_+$,满足$mathbf { x } ^ { + } = operatorname { argmax } _ { mathbf { x } _ { i } in mathbf { x } _ { 1 : t } } f left( mathbf { x } _ { i } ight)$,则

    [egin{aligned} mathrm { PI } ( mathbf { x } ) & = P left( f ( mathbf { x } ) geq f left( mathbf { x } ^ { + } ight) ight) \ & = Phi left( frac { mu ( mathbf { x } ) - f left( mathbf { x } ^ { + } ight) } { sigma ( mathbf { x } ) } ight) end{aligned}]

    其中$Phi ( cdot )$表示标准正态分布的分布函数。

    需要注意的是以上对于$x_{t+1}$的求解仅利用了已有信息,并没有很好权衡探索-利用之间的矛盾(对于探索-利用矛盾如果不了解可以阅读强化学习的一些基础内容),因此PI函数还具有以下变形:

    [egin{aligned} mathrm { PI } ( mathbf { x } ) & = P left( f ( mathbf { x } ) geq f left( mathbf { x } ^ { + } ight) + xi ight) \ & = Phi left( frac { mu ( mathbf { x } ) - f left( mathbf { x } ^ { + } ight) - xi } { sigma ( mathbf { x } ) } ight) end{aligned}]

    其中$xi geq 0$,一种建议的做法是刚开始训练时$xi$可以较大,加强探索,随算法迭代,$xi$应该逐渐减少,加强利用。

    Excepted Improvement(EI)

    EI的思想在于寻找具有最大改善期望的$x_{t+1}$,记选取$x_{t+1}$后,被改进的函数为$I(x)$,

    [mathrm { I } ( mathrm { x } ) = max left{ 0 , f _ { t + 1 } ( mathrm { x } ) - f left( mathrm { x } ^ { + } ight) ight}]

    我们做需寻找的$x_{t+1}$应满足

    [mathbf { x } = underset { mathbf { x } } { operatorname { argmax } } mathbb { E } left( max left{ 0 , f _ { t + 1 } ( mathbf { x } ) - f left( mathbf { x } ^ { + } ight) ight} | mathcal { D } _ { t } ight)]

    期望改进的计算公式还可以进行如下变形:

    [egin{aligned} mathbb { E } ( mathrm { I } ) & = int _ { mathrm { I } = 0 } ^ { mathrm { I } = infty } mathrm { I } frac { 1 } { sqrt { 2 pi } sigma ( mathbf { x } ) } exp left( - frac { left( mu ( mathbf { x } ) - f left( mathbf { x } ^ { + } ight) - mathrm { I } ight) ^ { 2 } } { 2 sigma ^ { 2 } ( mathbf { x } ) } ight) d mathrm { I } \ & = sigma ( mathbf { x } ) left[ frac { mu ( mathbf { x } ) - f left( mathbf { x } ^ { + } ight) } { sigma ( mathbf { x } ) } Phi left( frac { mu ( mathbf { x } ) - f left( mathbf { x } ^ { + } ight) } { sigma ( mathbf { x } ) } ight) + phi left( frac { mu ( mathbf { x } ) - f left( mathbf { x } ^ { + } ight) } { sigma ( mathbf { x } ) } ight) ight] end{aligned}]

    最终化简结果为:

    [operatorname { EI } ( mathbf { x } ) = left{ egin{array} { l l } { left( mu ( mathbf { x } ) - f left( mathbf { x } ^ { + } ight) ight) Phi ( Z ) + sigma ( mathbf { x } ) phi ( Z ) } & { ext { if } sigma ( mathbf { x } ) > 0 } \ { 0 } & { ext { if } sigma ( mathbf { x } ) = 0 } end{array} ight.]

    其中$Z = frac { mu ( mathbf { x } ) - f left( mathbf { x } ^ { + } ight) } { sigma ( mathbf { x } ) }$,并且$phi ( cdot )$为标准正态分布的概率分布函数(pdf),$Phi ( cdot )$为标准正态分布的分布函数(cdf)。

    EI算法同样可以加入探索-利用的权衡标量$xi$,满足$xi geq 0$,此时有

    [operatorname { EI } ( mathbf { x } ) = left{ egin{array} { l l } { left( mu ( mathbf { x } ) - f left( mathbf { x } ^ { + } ight) - xi ight) Phi ( Z ) + sigma ( mathbf { x } ) phi ( Z ) } & { ext { if } sigma ( mathbf { x } ) > 0 } \ { 0 } & { ext { if } sigma ( mathbf { x } ) = 0 } end{array} ight.]

    GP Upper Confidence Bound(GP-UCB)

    Upper Confidence Bound是Condidence bound criteria的一种,同样的还可以将准则设置为Lower Confidence Bound,这两个准则的效果是一样的,形式分别为:

    Lower Confidence Bound:[mathrm { LCB } ( mathbf { x } ) = mu ( mathbf { x } ) - kappa sigma ( x )]

    Upper Confidence Bound:[mathrm { UCB } ( mathbf { x } ) = mu ( mathbf { x } ) + kappa sigma ( x )]

    其中$kappa geq 0$一种选取$kappa$的方法来自于Srinivas(2010),采用后悔值进行计算,建议采用$kappa _ { t } = sqrt { u au _ { t } }$,

    其中超参数$ u > 0$,这样则有$mathrm { UCB } ( mathrm { x } ) = mu ( mathrm { x } ) + sqrt { u au _ { t } } sigma ( mathrm { x } )$

    记$x_*$为全局最优解,在$ u = 1, au _ { t } = 2 log left( t ^ { d / 2 + 2 } pi ^ { 2 } / 3 delta ight)$时,可以证明当协方差函数(核函数)相当平滑时有

    [lim _ { T ightarrow infty } R _ { T } / T = 0]

    其中,$R _ { T } = sum _ { t = 1 } ^ { T } f left( mathbf { x } ^ { star } ight) - f left( mathbf { x } _ { t } ight)$为后悔值的累计值。

    上图给出了上述三种方法的求解示例,不同颜色的线代表不同超参数下贝叶斯框架估计出的AC函数值,阴影部分则表示估计出的方差大小,PI方法趋向于选择概率上最大可能改进现有最好情况的点,EI方法则寻找的是带来改善效果期望值最大的点,GP-UCB则是将均值加方差作为目标函数。

  • 相关阅读:
    springcloud之Feign(五)
    ElasticSearch
    SpringCloud之Hystrix介绍
    SpringCloud之Ribbon负载均衡(四)
    springcloud之Eureka集群配置(三)
    Problem08 输入数字求和
    Problem07 处理字符串
    Problem06 求最大公约数及最小公倍数
    Problem05 判断分数等级
    Problem04 分解质因数
  • 原文地址:https://www.cnblogs.com/statruidong/p/10558089.html
Copyright © 2011-2022 走看看