Hello Potato World
[ํฌํ ์ดํ ์คํฐ๋] LRP: Layer-wise Relevance Propagation ๋ณธ๋ฌธ
[ํฌํ ์ดํ ์คํฐ๋] LRP: Layer-wise Relevance Propagation
Heosuab 2021. 8. 2. 01:40
โ ๏ฝก ห โ๏ธ ห ๏ฝก โ ๏ฝก ห โฝ ห ๏ฝก โ
[XAI study_ Interpretable Machine Learning]
20210802 XAI study ๋ฐํ์๋ฃ (์ฐธ๊ณ ๋ธ๋ก๊ทธ์ฃผ์ References)
LRP: Layer-wise Relevance Propagation

LRP : ๋ถํด๋ฅผ ํตํ ์ค๋ช (Explanation by Decomposition)์ ํตํด Neural Network์ ๊ฒฐ๊ณผ๋ฌผ์ ์ดํดํ ์ ์๊ฒ ๋์์ฃผ๋ ๋ฐฉ๋ฒ
input x๊ฐ ์ด d์ฐจ์์ผ๋ก ์ด๋ฃจ์ด์ ธ์๋ค๊ณ ํ๋ฉด, d์ฐจ์์ ๊ฐ๊ฐ์ feature๋ค์ด ์ต์ข output์ ๋์ถํ๋๋ฐ์ ์๋ก๋ค๋ฅธ ์ํฅ๋ ฅ์ ๊ฐ์ง๊ณ ์๋ค๊ณ ๊ฐ์ ํ๊ณ ์ด ๊ธฐ์ฌ๋(Relevance Score)๋ฅผ ๊ณ์ฐํ์ฌ ๋ถ์ํ๋ ๋ฐฉ๋ฒ์ด๋ค.

: sample image : ์ด๋ฏธ์ง x์ ๋ํ prediction "Rooster" : prediction ๋ฅผ ์ป๊ธฐ ์ํด ์ด๋ฏธ์ง x์ ๊ฐ pixel๋ค์ด ๊ธฐ์ฌํ๋ ์ ๋(๊ฐ ์ฐจ์์ Relevance Score)- LRP์ ๊ฒฐ๊ณผ heatmap : ์ด๋ฏธ์ง x์ ๊ฐ pixel๋ค์ Relevance Score๋ฅผ ์๊น๋ก ํ์
=> ์ค๋ฅธ์ชฝ ์๋จ(์ํ์ ๋ถ๋ฆฌ๋ ๋จธ๋ฆฌ)์ ๋ณด๊ณ x์ ๋ํ prediction์ "Rooster"๋ก ์ถ๋ ฅํ๋ค๋ ๊ฒ์ ์ ์ ์๋ค
Intuition & Mathematically
2-1. Intuition
LRP: Layer-wise Relevance Propagation (Top-down)
: Relevance score๋ฅผ Output layer์์ Input layer ๋ฐฉํฅ์ผ๋ก ๊ณ์ฐํด๋๊ฐ๋ฉฐ ๊ทธ ๋น์ค์ ์ฌ๋ถ๋ฐฐํ๋ ๋ฐฉ๋ฒ
- ๋ชจ๋ Neuron์ ๊ฐ๊ฐ์ ๊ธฐ์ฌ๋(Certain Relevance)๋ฅผ ๊ฐ์ง๊ณ ์๋ค
- Relevance๋ Top-down ๋ฐฉ์์ผ๋ก ์ฌ๋ถ๋ฐฐ
- ์ฌ๋ถ๋ฐฐ์ Relevance๋ ๋ณด์กด๋๋ค
(ex) "Rooster"์ prediction ํ๋ฅ ์ด 0.9์๋ค๊ณ ํ๋ค๋ฉด, Neuron๋ค์ Relevance score๋ฅผ ์ฌ๋ถ๋ฐฐํ ํ์ ๊ฐ layer์์์ relevance score์ ํฉ์ 0.9๋ก ๋ณด์กด๋์ด์ผ ํ๋ค.

2-1. Mathematically

Deep Neural Network์ prediction(
=> ๊ฐ Neuron์ input๊ณผ output์ ๊ด๊ณ ์ด์ฉ
(Relevance Score : input์ ๋ณํ์ ๋ฐ๋ฅธ ์ถ๋ ฅ์ ๋ณํ ์ ๋)

2์ฐจ์ ์
๋ ฅ(2weights, 1bias)์ ๊ฐ๋ Neuron
x๊ฐ์ ๋ณํ์ ๋ฐ๋ฅธ
output

์์ ๊ฐ์ด ํํ๋
Taylor Series
Taylor Series : ์ด๋ค ์ ์์ ๋ฌดํ ๋ฒ ๋ฏธ๋ถ๊ฐ๋ฅํ ํจ์๋ฅผ ๊ทธ ์ ์์ ๋ฏธ๋ถ๊ณ์ ๊ฐ์ผ๋ก ๊ณ์ฐํ ์ ์๋ ๋ฌดํ๊ธ์๋ก ํํ๋ ํจ์

2์ฐจ ์ด์์ ๋ฏธ๋ถ๊ณ์์ ํญ๋ค์ error(

์์ ์์์์ input์
2-dimension์์์ Taylor๊ธ์ ์์

๋ง์ฐฌ๊ฐ์ง๋ก error term์ ์ด์ฉํด ๋ํ๋ธ First-order Taylor Series

Middle term์ด Relevance score๋ฅผ ๊ฒฐ์ ํ๊ณ , x์ ๋ณํ์ ๋ฐ๋ฅธ
๋ถํ์ํ Term์ธ
- ReLU ํ์ฑํํจ์ ํน์ฑ์ ์ด์ฉํด
์ผ๋ก ๊ทผ์ฌ
ReLU ํน์ฑ์ ์ด์ฉํ
์์๋ก ์ฌ์ฉํ ๊ทธ๋ฆผ๊ณผ ๊ฐ์ด 2๊ฐ์ input

- case 1 : ์ด๋ฏธ 0์ ๊ฐ์ ๊ฐ์ง๋ฏ๋ก ๋ณํX
- case 2 : Taylor๊ธ์๋ก ํํ

Taylor๊ธ์๋ก ํํํ ์์
2์ฐจ ์ด์์ ํธ๋ฏธ๋ถ ๊ณ์๋ ๋ชจ๋ 0์ผ๋ก ๋์ค๊ธฐ ๋๋ฌธ์(๊ธฐ์ธ๊ธฐ ๋ณํ ์๋ ReLU์ ํน์ฑ), 2์ฐจ ์ด์์ ๋ฏธ๋ถ์ผ๋ก ํํํ
=> ๐=0

์ ๋ง๋๋ a๋ฅผ ์ฐพ๋ ๋ฐฉ๋ฒ

ํ๋์ Neuron์์, ๋ ๊ฐ์ ์
๋ ฅ๊ฐ
- ํฐ์์ ๊ฐ๊น์ธ์๋ก 0์ ๊ฐ๊น๊ณ ๋นจ๊ฐ์์ ๊ฐ๊น์ธ์๋ก ํฐ ๊ฐ
- ์ค์ ํ์ ์ง์ : ๋ชจ๋ ๊ฐ์ด 0์ธ ์ง์
- ์ ์ ํ์ ์ง์ : ๋์ผํ ๊ฐ์ ๊ฐ๋ ๋ฑ๊ณ ์
๊ทธ๋ฆผ์์์ ํ์ดํ vectorํํ(๊ด๊ณ)


๊ตฌํด์ง t๊ฐ์ ์ฌ์ฉํด ๋ค์ ๋ฒกํฐ x๋ฅผ ํํํ๋ฉด (a = x+tw์ ๋์ )

๋ฐ๋ผ์

Relevance Propagation Rule

์ ์ ํ a๋ฅผ ์ฐพ์์ผ๋ก์จ ํ๋์ Neuron์ ์ถ๋ ฅ

์์์ ๋ค๋ฃฌ ๊ฐ Neuron์์์ ๊ณ์ฐ ๋ฐฉ๋ฒ์ ์ ์ฒด Neural Network์ ์ ์ฉ
- Forward Pass : input
์ ๋ํ Neural Network์ ์ต์ข output - Relevance Propagation : ๊ฐ Neuron์ด ๊ฐ์ง๋ Relevance Score
๋ฅผ ์ ๋์ผํ๊ฒ ์ค์ ํ ๋ค์ ๊ณ์ํด์ Top-down ๊ณ์ฐ ์ํ
=> Neural Network์์ ๋ชจ๋ Neuron๋ค์ Relevance Score๋ฅผ ๊ณ์ฐํ ์ ์๊ฒ ๋๋ค.
Decomposition
Decomposition : input์ ๊ฐ feature๊ฐ ๊ฒฐ๊ณผ์ ์ผ๋ง๋ ์ํฅ์ ๋ฏธ์น๋์ง ํด์ฒดํ๋ ๋ฐฉ๋ฒ
(ex) Image x๋ฅผ "cat"์ผ๋ก ๋ถ๋ฅํ๋๋ฐ ๊ฐ hidden layer์์ ๊ณ์ฐํ ๊ธฐ์ฌ๋๋ฅผ ํ ๋๋ก ํด๋น input image x์ feature๋ค์ด ๋ชจ๋ธ์ ์ด๋ป๊ฒ ๋ฐ์๋ค์๋์ง ํํธ๋งต์ผ๋ก ๋์ํ
- Positive ์ํฅ์ ์ค feature : ๋นจ๊ฐ
- Negative ์ํฅ์ ์ค Feature : Blue
=> ์ด๋ง, ์ฝ, ์ ์ฃผ๋ณ์ pixel๋ค์ด ๊ฒฐ๊ณผ์ ์ํฅ์ ๋ง์ด ์ค ๊ฒ์ ํ์ธํ ์ ์๋ค

๋ฐ๋ผ์ LRP๋ Relevance Propagation๊ณผ Decomposition๋ฐฉ๋ฒ์ ์ฌ์ฉํด ๋ชจ๋ธ์ ํด๋ถํ๋ ๋ฐฉ๋ฒ์ด๋ค
Image Application Example
LRP๋ Image, Text ๋ฐ์ดํฐ ๋ฑ์ ๋ค์ํ๊ฒ ์ ์ฉ๋ ์ ์๋ค.
(Image Classification ๋ชจ๋ธ์ LRP๋ฅผ ์ ์ฉํ ๊ฒฐ๊ณผ)


References
[1] Explaining NonLinear Classification Decisions with Deep Taylor Decomposition, Montavon et al., 2015
[2] XAI ์ค๋ช ๊ฐ๋ฅํ ์ธ๊ณต์ง๋ฅ, ์ธ๊ณต์ง๋ฅ์ ํด๋ถํ๋ค, ์์ฌํ, 2020
[3] https://angeloyeo.github.io/2019/08/17/Layerwise_Relevance_Propagation.html
'Study๐ฅ > XAI' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํฌํ ์ดํ ์คํฐ๋] Detecting Concepts (0) | 2021.06.28 |
---|---|
[ํฌํ ์ดํ ์คํฐ๋] Pixel Attribution (Saliency Maps) (0) | 2021.06.28 |
[ํฌํ ์ดํ ์คํฐ๋] Influential Instances (0) | 2021.06.22 |
[ํฌํ ์ดํ ์คํฐ๋] Prototypes and Criticisms (0) | 2021.06.22 |
[ํฌํ ์ดํ ์คํฐ๋] Local Surrogate(LIME) (0) | 2021.05.24 |