在github看到這個(gè)文章寫的不錯(cuò),就轉(zhuǎn)載了,大家一起學(xué)習(xí):
https://github.com/keithyin/mynotes/tree/master/MachineLearning/algorithms
——————————————————————————————————————————
該作者也推薦了下面一個(gè)系列的文章,也寫的不錯(cuò):
- Variational inference
- KL(q∥p) minimization-1
- KL(p∥q) minimization-2
- VAE variation inference變分推理 清爽介紹
——————————————————————————————————————————

Variational Auto-Encoder

大家對(duì)貝葉斯公式應(yīng)該都很熟悉
我們稱為
posterior distribution。posterior distribution的計(jì)算通常是非常困難的,為什么呢?
假設(shè)是一個(gè)高維的隨機(jī)變量,如果要求
,我們不可避免的要計(jì)算
,由于
是高維隨機(jī)變量,這個(gè)積分是相當(dāng)難算的。
variational inference就是用來(lái)計(jì)算posterior distribution的。
core idea
variational inference的核心思想包含兩步:
- 假設(shè)分布
(這個(gè)分布是我們搞得定的,搞不定的就沒意義了)
- 通過(guò)改變分布的參數(shù)
, 使
靠近
總結(jié)稱一句話就是,為真實(shí)的后驗(yàn)分布引入了一個(gè)參數(shù)話的模型。 即:用一個(gè)簡(jiǎn)單的分布 擬合復(fù)雜的分布
。
這種策略將計(jì)算 的問(wèn)題轉(zhuǎn)化成優(yōu)化問(wèn)題了
收斂后,就可以用 來(lái)代替
了
公式推導(dǎo)
等式的兩邊同時(shí)對(duì)分布求期望,得
我們的目標(biāo)是使 靠近
,就是
由于 中包含
,這項(xiàng)非常難求。將
看做變量時(shí),
為常量,所以,
等價(jià)于
。
稱為Evidence Lower Bound(
ELBO)。
現(xiàn)在,variational inference的目標(biāo)變成
為什么稱之為ELBO呢?
一般被稱之為
evidence,又因?yàn)?, 所以
, 這就是為什么被稱為
ELBO。
ELBO
繼續(xù)看一下ELBO
The first term represents an energy. The energy encourages to focus probability mass where the model puts high probability
. The entropy encourages
to spread probability mass to avoid concentrating to one location.
包含K個(gè)獨(dú)立部分(K 維, 當(dāng)然,第i維也可能是高維向量),我們假設(shè):
這個(gè)被稱為mean field approximation。(關(guān)于mean field approximationhttps://metacademy.org/graphs/concepts/mean_field)
ELBO則變成
第一項(xiàng)為 energy, 第二項(xiàng)為H(q)
energy
符號(hào)的含義:
先處理第一項(xiàng):
其中 ,
保證
是一個(gè)分布。
與分布的參數(shù)
有關(guān),與變量無(wú)關(guān)??!
H(q)
再處理第二項(xiàng):
再看ELBO
經(jīng)過(guò)上面的處理,ELBO變?yōu)?br>
再看上式 中的項(xiàng):
所以ELBO又可以寫成:
我們要,如何更新
呢?
從
可以看出,當(dāng) 時(shí),
。 這時(shí),ELBO取最大值。
所以參數(shù)更新策略就變成了
關(guān)于
是要更新的節(jié)點(diǎn),
是觀測(cè)的數(shù)據(jù),由于
Markov Blanket(下面介紹),更新公式變成:
由于式子中和 無(wú)關(guān)的項(xiàng)都被積分積掉了,所以寫成了
Markov Blanket 這種形式
Markov Blanket
In machine learning, the Markov blanket for a node in a Bayesian network is the set of nodes
composed of
parents, its children, and its children's other parents. In a Markov random field, the Markov blanket of a node is its set of neighboring nodes.
Every set of nodes in the network is conditionally independent of when conditioned on the set
, that is, when conditioned on the Markov blanket of the node
. The probability has the Markov property; formally, for distinct nodes
and
:
The Markov blanket of a node contains all the variables that shield the node from the rest of the network. This means that the Markov blanket of a node is the only knowledge needed to predict the behavior of that node.
參考資料
https://en.wikipedia.org/wiki/Markov_blanket
http://edwardlib.org/tutorials/inference
http://edwardlib.org/tutorials/variational-inference