7. 기댓값 전파(Expectation Propagation)

2021. 8. 5. 15:43Bayesian

728x90

이전 글에서는 결합 분포의 우도를 최적화하는 과정에서 $\textrm {KL}(q||p)$를 최소로 만드는 $q(Z)$를 찾는 변분 베이즈 방법(Variational Bayes)에 대해 알아보았습니다.

이번 글에서는 사후분포를 최적화하는 방법 중 하나인 기댓값 전파(Expectation Propagation)에 대해 알아보겠습니다.

[관련 글] 6. 변분 베이즈 방법(Variational Bayes Method),6-1. 평균 장 근사(Mean-field approximation)


많은 경우에 결합 확률분포를 IID(Independent Identically Distributed) 분포의 곱으로 나타낼 수 있습니다. 즉, 다음과 같이 나타낼 수 있습니다. 

$p(\mathcal {D}, \theta)=\displaystyle \prod_{i}{f_i(\theta)}$

$p(\theta|\mathcal {D})=\frac {1}{p(\mathcal {D})} \displaystyle \prod_i {f_i(\theta)},~~~~where~ p(\mathcal{D})= \displaystyle \int{\displaystyle \prod_i{f_i(\theta)} d\theta }$

우리는 새로운 예측값을 만들 때, 이 사후 분포를 적분하여 만들게 되는데, 사후분포가 복잡한 형태여서 적분을 하지 못 하는 경우가 발생할 수 있습니다. 이때, 사후분포를 추정하는 방법이 기댓값 전파(Expectation Propagation)입니다.

$q(\theta)$를 다음과 같이 가정하겠습니다.

$q(\theta)=\frac {1}{Z} \displaystyle \prod_{i}{\tilde {f}_i(\theta)},~~~~where~ Z= \displaystyle \int {\displaystyle \prod_{i}{\tilde {f}_i(\theta)}}$

우리가 최소화할 KL Divergence는 다음과 같습니다.

$\textrm {KL}(p||q)=\textrm {KL}\left ( \frac {1}{p(\mathcal {D})} \displaystyle \prod_i {f_i(\theta)}  ||  \frac {1}{Z} \displaystyle \prod_{i}{\tilde {f}_i(\theta)} \right )$

하지만 데이터에 대한 분포는 알고 있지만, 사후 분포는 알고 있지 못하기 때문에, 우리가 알고 있는 $q(\theta)$분포를 이용해서 $f_j(\theta)$분포 하나씩 업데이트하게 됩니다. (우리가 알고 있는 $q(\theta)$분포와 $j$번째 요소를 바꾼 분포 간의 KL Divergence를 줄이면서 최적화를 진행하게 됩니다.) 즉, 다음과 같은 KL Divergence를 최적화합니다. 

$\textrm {KL}\left ( \frac {1}{Z_j } f_j(\theta) q^{\backslash {j} }(\theta) || q(\theta) \right ),~~~~where~~ q^{\backslash {j} }(\theta)=\frac {q(\theta)}{\tilde {f}_j(\theta)},~~Z_j=\displaystyle \int {f_j(\theta) q^{\backslash {j}}(\theta) \textrm {d}\theta}$

한편, $q(\theta)$의 분포를 지수족이라고 가정했기 때문에, 다음과 같은 식들이 성립합니다.

$\textrm {KL}(p||q)=-\textrm {ln}~g(\eta)-\eta^{T} \mathbb {E}_{p(z)}[u(z)]+\textrm {const}$

위 식을 최적화 하기 위해 미분한 후, 0이 되는 값을 찾아주면 다음과 같습니다.

$-\nabla~\textrm {ln}~g(\eta) = \mathbb {E}_{p(z)}[u(z)]$

$-\nabla~\textrm {ln}~g(\eta) =-\frac {1}{g(\eta)} \nabla~g(\eta) = \displaystyle \int {g(\eta) h(x)~exp \{ \eta^{T} u(x) \} u(x) dx }=\mathbb {E}_{q(z)}[u(x)] $

즉, $\mathbb {E}_{p(z)}[u(x)] = \mathbb {E}_{q(z)}[u(x)]$ 이 성립합니다.

만약 $u(x)$가 충분 통계량인 경우, 기댓값이 같을 때, 두 분포의 모멘트는 같게 되는데, 이것을 moment matching이라고 합니다. moment matching 방법을 이용하여 위 식의 $\tilde {f}_j(\theta)$을 찾아줄 수 있습니다.