Deep learning기법을 이상진단 등에 적용할 경우, 정상과 이상 data-set간의 심각한 unbalance가 문제. 본 논문에서는 GAN 기법을 이용하여 정상 data-set만의 Manifold(축약된 모델)를 찾아낸 후 Query data에 대하여 기 훈련된 GAN 모델로 Manifold로의 mapping을 수행함으로서 기 훈련된 정상 data-set과의 차이가 있는지 여부를 판단하여 Query data의 이상 유무를 결정하고 영상 내에 존재하는 이상 영역을 pixel-wise segmentation 하여 제시함.
1. Anomaly Detection with GANs
https://arxiv.org/abs/1703.05921
Postech 이도엽씨가 구현한 Tensorflow 코드
https://github.com/LeeDoYup/AnoGAN
2. 처음 접하는 분들을 위하여 우선
Generative Adversarial Network부터
간단히 알아보자
3. 판별모델(discriminative model)이 아닌 생성모델(generative model) !
판별모델 생성모델
• 많아 봐왔던 일반적인 기계학습은 판별모델(class별 확률계산)
- class를 나누기 위해 선(decision boundary)을 찾는다 !
• 생성모델은 판별하는 것이 아니라 class별 범위(distribution)를 찾는다 !
GAN, VAE
Generative Adversarial Network 이란 ?
4. 왜 이런 어려운 모델까지 ?
Curse of Dimensionality
• In many applications, we simply vectorize an image or image patch
• 256 x 256 image converts to a 65,536-dimensional vector.
• Images, therefore, are typically very high-dimensional data
• Affects the convergence of any learning algorithm.
• In some applications, we know that there are only a few variables, for e.g.,
face pose and illumination.
• Data lie on some low-dimensional subspace/manifold in the high-dimensional
space.
주어진 data set의 축약된 모델(Manifold)을 찾아보자 !
5. 특징이 서로 얽혀 있어 해석이 불가능한 Physical space에서
해석이 용이하도록 서로 독립적인 Eigen space로 변환하는 것 처럼
영향이 매우 작으므로
무시
Manifold Assumption
6. • Data lie approximately on a manifold of much lower
dimension than the input space
• Mapping between two space is unique & reversible
Manifold Assumption
7. Manifold Assumption
- The curse of dimensionality can be mitigated under the manifold assumption.
- Linear dimensionality reduction techniques like PCA have been widely used in
the vision community.
- Recent trend is towards non-linear techniques that recover the intrinsic
parameterization (pose, emotion, illumination, etc mode).
8. GAN이란 ?
• GAN: Generative Adversarial Networks [Goodfellow+,2014]
– Generator (G)와 Discriminator (D)를 서로 경쟁시켜서
생성 정확도의 향상을 도모하는 모델
9. GAN이란?
GAN: Generative Adversarial Networks [Goodfellow+,2014]
• Generator (G)와 Discriminator (D)를 서로 경쟁시켜서
생성 정확도의 향상을 도모하는 모델
• G : 생성용 벡터 z로부터 데이터를 생성
• D : 대상 데이터가 진짜(데이터 세트)
인가 가짜(G에 의해 생성)를 식별
데이터셋의 데이터를
「진짜」로 식별
생성된 데이터를「위조」로 식별
10. D(Image) : Discriminator에 의해 계산된 “image가 real일 확률”
Discriminator가 「진짜」에 대해서는 “1”에 가깝도록
Generator가 생성한 「위조」에 대해서는 “0”에 가깝도록
D(x) 1, D(G(z)) 0 이 되도록
log(1-G(x))
G(x)
log(x)
x
11. 2 개의 모델을 만들어 경쟁시킴으로써 데이터의 분포를 학습시키는
비지도학습 프레임 워크
: Generator에 의해 예측된 데이터 분포
14. Anomaly detection : 정상치에서 벗어난 관측치들을 detect
One-class classification 혹은 one-class description
Anomaly detection 문제점 : 보통 현실에서는 비정상 관측치가 거의
없는 경우가 많기 때문
통상 제조 공정에서 관리되는 품질 수준이 ppm단위
이런 경우에는 정상 관측치를 모델링함으로서 그 모델에서 벗어나는
정도를 기반으로 fault detection
15. 이 연구에서는 아래 그림처럼 정상 data만으로 학습시킨 GAN
모델를 이용하여 Query data에 대하여 정상여부는 물론
비정상 시 비정상 영역을 찾아내고자 함.
16. 1. 정상 data를 이용하여 Generator & Discriminator의 훈련
- Deep convolutional generative adversarial network을 이용하여
latent space(z)로 부터 Generator를 이용하여 생성된 image와
Real image를 구별하도록 Discriminator를 훈련
정상 data의 latent space(z) 분포를 학습
2. 비정상 data여부와 비정상 영역 파악
- 훈련된 Generator & Discriminator의 parameter를 고정한 채
Query image에 대한 latent space(z)로의 mapping 작업을 수행
훈련된 정상 data의 경우, 기학습된 정상 data의 latent space(z) 로
mapping이 되지만, 비정상 data의 경우 벗어남
cost function의 오차가 발생
Anomaly Detection은 다음과 같이 2단계로 이루어짐
17. 1. GAN을 이용하여 정상 data 모델링하기
: 정상 data의 generative model(distribution)을 GAN을 이용하여 학습
정상 𝑑𝑎𝑡𝑎 𝐼 𝑚, with m = 1,2,.....,M, where 𝐼 𝑚 ∈ 𝑅 𝑎𝑥𝑏
임의의 위치에서 랜덤하게 cxc크기의 K 2-D image
patches를 추출 x = 𝑥 𝑘,𝑚 ∈ ℵ with k = 1,2,……,K.
D and G are simultaneously optimized through the following two-
player minimax game with value function V (G,D)
The discriminator is trained to maximize the probability of assigning
real training examples the “real” and samples from 𝑝 𝑔the “fake” label
18. 2. Query data의 latent space Mapping
Query image x가 주어질 경우, 이와 가장 유사한 가상 image인 G(z) 에
해당하는 latent space상의 점 z을 찾는다.
x 와 G(z)의 유사여부는 query image가 generator의 훈련시 사용된 정상
data의 분포 𝑝 𝑔를 어느 정도 따르느냐에 의해 결정
z을 찾기 위하여 , latent space distribution Z에서 랜덤하게 샘플된 z1 을
기훈련된 generator에 입력하여 얻은 출력 G(z1)와 x의 차(loss ft’n)를 최
소화하도록 backpropagation을 통하여 latent space의 점z2로 update
19. z
정상 image의 Latent space(z)가 1차원이라고 가정하고
Z은 다음과 같은 분포로 가정하면
𝜇 𝑧
z𝜇 𝑧
Query image에 대한 latent space(z) mapping은
i) 임의의 값 𝑧1에서 시작하여 loss ft’n을 최소화하도록 update
ii) 주어진 Γ번째 iteration 후 𝑧Γ이 allowable range안에 들어왔는지
여부에 때라 정상, 비정상을 구분
𝑧1 𝑧2 𝑧Γ
Allowable range
20. • Overall loss or Anomaly score:
• Anomaly score consists of two parts:
• Residual Loss - visual similarity
• Discrimination Loss - enforces the generated image to lie on the manifold
Query Image의 Mapping에 대한 Loss function 정의
21. Improved discrimination loss based on feature matching
• f(.) – output of intermediate layer of the discriminator
• It is some statistics of an input image
This approach utilizes the trained discriminator not as classifier
but as a feature extractor
22. 3. Anomaly Detection
Anomaly score : query image x가 정상 image에 얼마나 부합하는지 여부
R(x) : Γ번의 backpropagation후 Residual loss
D(x) : Γ번의 backpropagation후 Discrimination Loss
비정상 image : A(x) is large
정상 image : A(x) is small
𝑥 𝑅 = 𝑥 − 𝐺 𝑧Γ
Residual error : image내의 비정상 영역을 나타냄
23. 4. Experiments
실험대상은 망막층을 3차원적으로 관측하는 빛간섭단층촬영(OCT) 영상
• Data, Data Selection and Preprocessing
i) Training sets :
- 2D image patches extracted from 270 clinical OCT volumes of healthy subjects
- The gray values were normalized to range from -1 to 1.
- Extracted in total 1,000,000 2D training patches with an image resolution of
64x64 pixels at randomly sampled positions.
24. ii) Testing sets :
- patches were extracted from 10 additional healthy cases and 10
pathological cases, which contained retinal fluid
- Test set in total consisted of 8,192 image patches and comprised
normal and pathological samples
25. iii) Model description
- Adopt DCGAN architecture that resulted in stable GAN training on
images of sizes 64x64 pixels.
- Utilized intermediate representations with 512-256-128-64 channels
(instead of 1024-512-256-128)
- Discrimination loss : Feature representations of the last convolution
layer of the discriminator was used
- Training was performed for 20 epochs utilizing Adam optimizer.
- Ran 500 backpropagation steps for the mapping of new images to the
latent space.
- Used λ= 0.1 in loss function
26. i) Generative capability of the DCGAN
5. Experiments
Given image
Generated image
Residual overlay
Pixel-level annotations
of retinal fluid
Normal image Anomalous image
27. ii) Detection performance
ROC curves
Distribution of the residual score(c)
and of the discrimination score(d)
Latent space에서 정상 data(trained data 및 test data 중 정상)간의 분포는
유사하나 Test data 중 비정상과는 확실한 차이를 나타냄