A Simple Unified Framework for Detecting Out-of-Distribution Samples and Adversarial Attacks












Preliminary
우선 Supplementary A에 대한 간단한 리뷰가 필요해 보임. Classifier는 크게 discriminative 와 generative classifier 두 가지로 나뉨. discriminative는 x가 주어졌을 때 어떤 class(y)인지 직접적으로 예측함, 즉 P(y|x). 대표적인게 softmax classifier이고 posterior distribution이 다음과 같이 정의됨.

genertive classifier는 posterior distribution P(y|x) = P(x|y)P(y)/P(x)를 구하기 위해 class prior 확률, P(y)와 class conditional distribution P(x|y)를 정의하고, 각각 Bernoulli와 Gaussian Distribution을 따른다고 가정함. 여기에 약간의 가정(LDA : 모든 class들이 같은 covariance matrix를 가진다)를 더하면, 이렇게 정의한 generative classifier도 softmax function의 형태를 가짐을 보여줌. 이 논문에서 ‘genertive classfier를 사용했다’ 함은 위와 같은 맥락에서 이해해야 함 : P(y|x)를 직접적으로 구해서 이용하는 것의 한계를 극복하고자, P(x|y)를 거쳐서 P(y|x)를 구함. 이 위 confidence score를 개선하고 여러 technique을 더함.
주요 points
ICLR2018 논문에서 Joint Confident Loss를 사용하여 OOD Detection 성능 개선을 이루어 냈지만, 추가 개선 진행해 기존 best (fig. 7에서 Joint Confident loss + base line, Joint Confident loss + ODIN)을 능가하는 성능을 달성함.


- 이미 Pre-train된 Softmax Classifier가 있다고 가정. 이 pre-trained classifier의 중간 layer의 hidden feature space 상 에서는 class간 분포를 그려보면 Gaussian 분포를 따른다 가정(Fig 1a)
- softmax classifier의 마지막 layer (overfitting이 많이 된)에서 OOD를 잡아내는 것보다 중간 hidden space에서 잡아내는 것이 용이할 수 있다는 가정이 숨어 있음.
- 이런 가정을 기반으로 pre-trained classifier로부터 ‘generative classifier’를 추가로 만듬. 이 때 각 class의 mean과 co-variance는 trainnig 샘플로부터 얻음.
- Test 샘플(또는 OOD)과 In-Distribution 샘플 (Gaussian 분포를 따른다 가정한)과의 거리를 Mahalanobis Distance(MD)를 이용해 구하고, 이 거리를 Test 샘플의 Confidence Score를 이용하여 Score가 특정 threshold 이하이면 OOD 샘플로 판정.
- 추가 개선을 위해 test 샘플을 있는 그대로 넣지 않고 noise를 넣어서 pre-precess된 샘플을 이용. Gradient 기반으로 Adversarial noise를 넣는 것과 비슷하나 방향은 반대임 : Noise를 넣는 방향은 confidence score를 높이는 방향.
- 또 추가 개선을 위해 MD를 구할 때 어떤 중간 layer에서 구하느냐를 결정하는게 쉽지 않으니, ensemeble로 해서 성능 개선.
Why Mahalanobis Distance(MD)?
Hidden Feature Space에서 그린 아래 cluster x (in-dist 샘플 중 특정 class)의 distribution이 단순한 spherical이 아니고 ellipsiod라면 test 샘픔 blue point, yellow point 사이의 거리는 yellow point가 더 멀다고 볼 수 있음. 이와 같이 feature간 correlation이 있을 수 있고, 즉 이러한 co-variance를 고려해서 거리를 구하는 것이 MD임. 즉 distribution의 center에서 test 샘플까지의 거리를 구하고 이를 다시 test 샘플의 방향으로 co-variance의 크기로 나눠줌.


여기서, f(x)는 DNN 중간 layer에서 output, c : class, mu : mean of class, sigma : covariance임
Robust Inference via Generative Classifiers for Handling Noisy Labels
앞선 논문에서 generative classifier를 이용하여 OOD 샘플을 detection하는 성능을 올림. 이러한 generative classifier가 noisy label을 다루는 데도 도움이 될 수 있는 고려한 논문이 본 논문임. 일반적으로 generative classifier를 만들 때 class의 분포를 Gaussian 분포로 가정하고 mean과 co-variance를 구하고 이를 바탕으로 Mahalanobis Distance(MD)를 구하여 OOD 샘플 detection함. 하지만 이 때 label에 noise가 있을 경우, 이러한 outlier 때문에 co-variance가 정확하게 측정되지 않을 가능성이 많음. 이를 개선하기 위해 minimum covariance determinant(MCD) estimation이라는 방법을 이용하여, outlier가 있는 상황에서도 보다 정확하게 mean과 co-variacnce를 측정하게 함. Fig 1c에서 보듯이 MCD를 이용하면 outlier를 무시하면서 조금 더 정확하게 샘플들의 distribution 특성을 고려할 수 있음.

여기서 나올 수 있는 질문 하나가, MD를 계산할 때 softmax classifier의 중간 layer의 feature들을 이용하기 때문에 noisy한 label이 있는 상황에서 softmax classifier가 data의 중요한 pattern을 배울 수 있느냐임. Fig 1b에서 가능함을 보여주고 있음. Fig 1a에서 보듯이 generative + MCD를 쓴 경우 (blue, green)가 noisy 샘플이 있는 환경에서 가장 우수한 모델 성능을 보임. 일반적인 softmax classifier의 성능 (black line)이 nosy lable이 있는 상황에서 가장 좋지 않고, generative classifier를 쓸 때 noisy 샘플에서 mean과 co-variance를 추정한 경우(yellow)는 성능 개선이 되긴 하나 한계가 있음.