or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
tags:
ML數學分部
KL Divergence & CrossEntrophy 的真面目
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →很多 ML 初學者(Me) 一定都有聽過 CrossEntrophy ,甚至知道他的計算原理
這邊有我看過的一篇文章講的還蠻好理解的 - "文章連結"
但本文想從另一個角度 KL Divergence 切回 CrossEntrophy
這樣可以更直觀看待 loss 的意義,且 Divergence 一詞在 GAN 也會常看到 (我也是遇到了才知道…)
先簡單提一下, Divergence 可以被看作是一種機率分布的"差異",
KL Divergence 則是最基礎的 Divergence
CrossEntrophy 其實就是 KL Divergence 的變形。
1. KL Divergence
這邊用一個簡單的例子來說明 KL Divergence
example -
有兩硬幣,出現正反面的機率各不相同
Step1.
Step2.
Step3.
Step4.
Step5. 算出 KL Divergence
Step6. Summary
KL-Divergence 公式
\[D_{KL}( P || Q )=\sum_i{P(i)log(\frac{P(i)}{Q(i)})}\]
2. CrossEntrophy
剛剛講完 KL Divergence,我們知道可以用來量測兩機率分佈的"差異性"
CrossEntrophy 更直觀的把他用在計算"實際資料"與"預測資料"分佈的差異上
接著要計算 Data 間的差異,也就是 KL Divergence
因為我們之後會想要所小差距,使預測更接近實際結果
所以任務會是最小化 \(D_{KL}\)
Summary
Cross Entrophy 公式
\[CrossEntrophy = - \sum_i{P^*log(P)}\]
3. CrossEntrophy & Softmax 關係
在知道 CrossEntrophy 與 KL Divergence 後,
可以很簡單就理解為什麼 CrossEntrophy 前都要用 Softmax 了
4. Reference