当前位置:   article > 正文

条件随机场CRF

条件随机场CRF

CRF条件随机场

知识点

  1. 有向图无向图
    在这里插入图片描述
  2. log linear model
    通用形式:
    P ( y ∣ x , w ) = e x p ( ∑ j w j F j ( x , y ) ) z ( x , w ) P(y|x,w)=\frac{exp(\sum_{j}w_{j}F_{j}(x,y))}{z(x,w)} P(yx,w)=z(x,w)exp(jwjFj(x,y))
    F为feature function,有不同的构造方法。
  • 逻辑回归(LR)
  • 条件随机场(CRF)
    P ( y ˉ ∣ x ˉ , w ) = 1 z ( x ˉ , w ) e x p ∑ j = 1 J w j F j ( x ˉ , y ˉ ) = 1 z ( x ˉ , w ) e x p ∑ j = 1 J w j ∑ i = 2 n f j ( y i − 1 , y i , x ˉ , i )
    P(y¯|x¯,w)=1z(x¯,w)expj=1JwjFj(x¯,y¯)=1z(x¯,w)expj=1Jwji=2nfj(yi1,yi,x¯,i)
    P(yˉxˉ,w)=z(xˉ,w)1expj=1JwjFj(xˉ,yˉ)=z(xˉ,w)1expj=1Jwji=2nfj(yi1,yi,xˉ,i)
  1. Inference
    y ^ = a r g m a x   P ( y ˉ ∣ x ˉ , w ) = a r g m a x   ∑ j = 1 J w j F j ( x ˉ , y ˉ ) = a r g m a x   ∑ j = 1 J w j ∑ i = 2 n f j ( y i − 1 , y i , x ˉ , i ) = a r g m a x   ∑ i = 2 n g i ( y i − 1 . y i ) g ( y i − 1 , y i ) = ∑ j = 1 J w j f j ( y i − 1 , y i , x ˉ , i )

    y^=argmax P(y¯|x¯,w)=argmax j=1JwjFj(x¯,y¯)=argmax j=1Jwji=2nfj(yi1,yi,x¯,i)=argmax i=2ngi(yi1.yi)g(yi1,yi)=j=1Jwjfj(yi1,yi,x¯,i)
    y^g(yi1,yi)=argmax P(yˉxˉ,w)=argmax j=1JwjFj(xˉ,yˉ)=argmax j=1Jwji=2nfj(yi1,yi,xˉ,i)=argmax i=2ngi(yi1.yi)=j=1Jwjfj(yi1,yi,xˉ,i)
    求解使 y ^ \hat{y} y^最大的 y ˉ \bar{y} yˉ,使用Viterbi算法求解。

  2. w的参数估计
    ∂ ∂ w j log ⁡ P ( y ∣ x , w ) = ∂ ∂ w j [ ∑ j = 1 J w j F j ( x , y ) − log ⁡ z ( x , w ) ] = F j ( x , y ) − 1 z ( x , w ) ∂ ∂ w j z ( x , w ) = F j ( x , w ) − ∑ y ′ F j ( x , y ′ ) ⋅ P ( y ′ ∣ x , w ) = F j ( x , y ) − E ( F j ( x , y ′ ) ) E q u a t i o n 1

    wjlogP(y|x,w)=wj[j=1JwjFj(x,y)logz(x,w)]=Fj(x,y)1z(x,w)wjz(x,w)=Fj(x,w)yFj(x,y)P(y|x,w)=Fj(x,y)E(Fj(x,y))Equation1
    wjlogP(yx,w)=wj[j=1JwjFj(x,y)logz(x,w)]=Fj(x,y)z(x,w)1wjz(x,w)=Fj(x,w)yFj(x,y)P(yx,w)=Fj(x,y)E(Fj(x,y))Equation1
    P ( y k = u ∣ x ˉ , w ) = α ( k , u ) ⋅ β ( u , k ) z ( x ˉ , w ) P(y_{k}=u|\bar{x},w)= \frac{\alpha(k,u)\cdot \beta(u,k)}{z(\bar{x},w)} P(yk=uxˉ,w)=z(xˉ,w)α(k,u)β(u,k)
    P ( y k = u , y k + 1 = v ∣ x ˉ , w ) = α ( k , u ) e x p [ g k + 1 ( u , v ) ] β ( u , k ) z ( x ˉ , w ) E q u a t i o n 2 P(y_{k}=u,y_{k+1}=v|\bar{x},w) = \frac{\alpha(k,u)exp[g_{k+1}(u,v)]\beta(u,k)}{z(\bar{x},w)} \quad \quad \quad Equation 2 P(yk=u,yk+1=vxˉ,w)=z(xˉ,w)α(k,u)exp[gk+1(u,v)]β(u,k)Equation2
    ∂ ∂ w j log ⁡ P ( y ˉ ∣ x ˉ , w ) = F j ( x ˉ , y ˉ ) − E ( F j ( x , y ′ ) ) = F j ( x ˉ , y ˉ ) − E y ˉ [ ∑ i = 2 n f j ( y i − 1 , y i , x ˉ , i ) ] = F j ( x ˉ , y ˉ ) − E y i − 1 , y i [ ∑ i = 2 n f j ( y i − 1 , y i , x ˉ , i ) ] = F j ( x ˉ , y ˉ ) − ∑ i = 2 n ∑ y i − 1 ∑ y i f j ( y i − 1 , y i , x ˉ , i ) ⋅ P ( y i , y i − 1 ∣ x ˉ , w ) = F j ( x ˉ , y ˉ ) − ∑ i = 2 n ∑ y i − 1 ∑ y i f j ( y i − 1 , y i , x ˉ , i ) ⋅ α ( i − 1 , y i − 1 ) e x p [ g i ( y i − 1 , y i ) ] β ( y i , i ) z ( x ˉ , w )
    wjlogP(y¯|x¯,w)=Fj(x¯,y¯)E(Fj(x,y))=Fj(x¯,y¯)Ey¯[i=2nfj(yi1,yi,x¯,i)]=Fj(x¯,y¯)Eyi1,yi[i=2nfj(yi1,yi,x¯,i)]=Fj(x¯,y¯)i=2nyi1yifj(yi1,yi,x¯,i)P(yi,yi1|x¯,w)=Fj(x¯,y¯)i=2nyi1yifj(yi1,yi,x¯,i)α(i1,yi1)exp[gi(yi1,yi)]β(yi,i)z(x¯,w)
    wjlogP(yˉxˉ,w)=Fj(xˉ,yˉ)E(Fj(x,y))=Fj(xˉ,yˉ)Eyˉ[i=2nfj(yi1,yi,xˉ,i)]=Fj(xˉ,yˉ)Eyi1,yi[i=2nfj(yi1,yi,xˉ,i)]=Fj(xˉ,yˉ)i=2nyi1yifj(yi1,yi,xˉ,i)P(yi,yi1xˉ,w)=Fj(xˉ,yˉ)i=2nyi1yifj(yi1,yi,xˉ,i)z(xˉ,w)α(i1,yi1)exp[gi(yi1,yi)]β(yi,i)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/374789
推荐阅读
相关标签
  

闽ICP备14008679号