Dreaming to Distill; Data-free Knowledge Transfer via DeepInversion

|


Hongxu Yin, Pavlo Molchanov, Zhizhong Li, Jose M. Alvarez, Arun Mallya, Derek Hoiem, Niraj K. Jha, Jan Kautz
[NVIDIA, Princeton University, University of Illinois]
[Submitted on 18 Dec 2019 (v1), last revised 16 Jun 2020 (this version, v2)]
arXiv: https://arxiv.org/abs/1912.08795

Abstract

Google이 발표한 DeepDream에서 더 다양한 loss와 방법론을 추가하여 성능을 완전히 끌어올린 논문.
추출한 합성 데이터를 통하여 Data-free knowledge transfer, data-free network pruning, data-free continual learning을 보여줌.


1. Introduction

image

현재까지의 knowledge transfer의 경우, original data에 대한 접근이 필요했음. 근데 user privacy, security, proprietary concerns 또는 competitive disadvantage 때문에 몇몇 기업은 학습 데이터를 제공하는 것을 꺼려할 수 있음.

학습 데이터에 대한 사전 지식이나 메타 정보 없이 복원할 수 있는 방법을 찾고자 함.

가장 이용하기 쉽고 인기있었던 메서드는 DeepDream이 존재함. DeepDream의 경우, 이미 학습된 classifier에 input image를 넣어서 선택한 클래스에 대해 가장 높은 response를 나타내도록 input image를 합성 및 변형하는 방식을 보임.

이 방식은 아마 몇개의 regularizer들로 랜덤 노이즈이거나 아니면 다른 natural image와 같은 input을 최적화함. 대신 그 동안 선택된 output activation들은 고정시켜놓고 중간의 representation들은 constraint-free 상태로 둔다.

이를 통해 나온 결과 이미지들은 굉장히 부자연스러워 보인다. 그래서인지 knowledge transfer에서 엄청 쓸모있지는 않다고 함.

본 논문에서는 실생활에서 적용이 가능한 방식을 찾고자 하는데 여기서 사용한 prior knowledge는 모델안의 BN layer statistics이다. BN layer는 activation들의 running mean과 variance들을 저장하는데 이를 통해 original data의 정보를 어느정도 활용할 수 있다는 점을 이용한다. 저자들이 제안하는 방식의 이름은 DeepInversion임.

여기다가 생성되는 가상 이미지들의 다양성을 좀 더 고려하는 loss를 추가한 버전을 Adaptive DeepInversion이라 칭함.

3. Method

3.1. Background

Knowledge Distillation

Knowledge distillation은 teacher와 student 모델의 distribution을 비슷하게 만드는 제약조건을 걸어서 teacher의 knowledge를 student로 전달하는 방식임.

Teacher model : $p_T$ Dataset : $\mathcal{X}$ Parameters of the student model : $W_S$

위 노테이션을 사용하여 $W_s$ 학습과정을 아래 식으로 표현이 가능함.

\[\min_{W_S} \sum_{x \in \mathcal{X}}KL(p_T(x), p_S(x))\]

여기서 $KL(\cdot)$ 는 Kullback-Leibler divergence를 의미하고 $p_T(x) = p(x,\textbf{W}_T)$, $p_S(x) = p(x, \textbf{W}_S)$ 는 teacher와 student 모델에서 각각 생산한 output distribution을 의미함.

KD에서는 ground truth가 필요하지 않다는 것이 장점. 효율적인 대신에 과정 자체가 같은 도메인의 real image에 의존한다는 단점도 존재함. 그래서 저자들은 이 real image를 noise로부터 새롭게 생성해내는 방식에 초점을 맞추려함.

DeepDream

원래 이 메서드는 natural image에 artistic effect를 끌어올리는것으로 사용되었다. 근데 또 noise를 optimize하는데도 적합하기도 함.

random으로 초기화가 된 input $\hat{x} \in \mathcal{R}^{H \times W \times C}$ 와 임의의 target label $y$가 주어졌을 때 image는 아래 식을 optimize 하는 방향으로 합성이 진행된다.

\[\min_{\hat{x}} \mathcal{L}(\hat{x}, y) + \mathcal{R}(\hat{x})\]

여기서 $\mathcal{L}(\cdot)$ 은 classification loss (e.g., cross-entropy) 이고 $\mathcal{R}(\cdot)$ 은 image regularization term이다.

DeepDream은 image prior을 이용하여 식별 가능한 시각 정보가 없는 unrealistic image들로부터 $\hat{x}$ 를 멀리 떨어지도록 하는데 아래 식을 사용한다.

\[\mathcal{R}_{prior}(\hat{x}) = \alpha_{tv} \mathcal{R}_{TV}(\hat{x}) + \alpha_{l_2} \mathcal{R}_{l_2}(\hat{x})\]

위 식에서 \(\mathcal{R}_{TV}\) 와 \(\mathcal{R}_{l_2}\) 는 \(\hat{x}\)의 total variance와 \(l_2\) norm에 대한 regularization term 이다.

실험적으로 봤을 때, image prior regularization 은 valid image들에 대한 더욱 안정적인 convergence를 제공하는 것을 확인하였다고 한다. 그러나 여전히 생성된 이미지들은 natural image들과는 상당히 거리가 있는 분포를 가지게 되고 이에 따라 KD 성능에 좋지 못한 결과를 일으킬 수 있다고 지적함.

3.2. DeepInversion (DI)

저자들은 새로운 feature distribution regularization term으로 기존의 image regularization term인 $\mathcal{R}(\hat{x})$을 확장하여 DeepDream의 이미지 퀄리티를 올리는 방법을 선보인다.

기존의 image prior term은 기존의 데이터셋인 $x \in \mathcal{X}$ 의 low- 와 high-level feature와 유사한 합성의 데이터 $\hat{x} \in \hat{\mathcal{X}}$ 을 얻는 little guidance만을 제공한다.

하지만 모든 레벨에서 feature similarity를 효과적으로 극대화하기 위해서, 저자들은 $\hat{x}$와 $x$의 feature map statistics 간의 거리를 최소화하는 것을 시도한다.

우선 저자들은 feature statistics가 배치를 아울러 Gaussian 분포를 따른다고 가정했다. 그렇기 때문에 mean $\mu$ 와 variance $\sigma^2$로 정의가 가능해진다.

그리고 나서 feature distribution regularization term 을 다음과 같이 정의함.

\[\mathcal{R}_{feature}(\hat{x}) = \sum_l{\parallel \mu_l(\hat{x} - \mathbb{E}(\mu_l(x)|\mathcal{X})) \parallel_2} + \sum_l{\parallel \sigma^2_l(\hat{x} - \mathbb{E}(\sigma^2_l(x)|\mathcal{X}))\parallel_2}\]

여기서 $\mu_l(\hat{x})$ 와 $\sigma^2_l(\hat{x})$ $l^{th}$ convolutional layer에 대응하는 feature map의 batch-wise mean과 variance estimate이다.

여기서 $\mathbb{E}(\mu_l(x) \vert \mathcal{X})$ 와 $\mathbb{E}(\sigma^2_l(x)\vert \mathcal{X})$ 는 실제 데이터의 접근이 필요하기 때문에 이를 피하기 위해서 저자들은 BN layer의 statistic estimation을 사용하기로 한다.

\[\mathbb{E}(\mu_l(x) \vert \mathcal{X}) \simeq BN_l(running\_mean)\] \[\mathbb{E}(\sigma^2_l(x) \vert \mathcal{X}) \simeq BN_l(running\_variance)\]

그래서 결과적으로 저자들은 DeepDream의 loss term에서 $\mathcal{R}$을 더욱 구체적으로 나타낼 수 있게 되었다.

\[\min_{\hat{x}} \mathcal{L}(\hat{x}, y) + \mathcal{R}(\hat{x}) = \min_{\hat{x}} \mathcal{L}(\hat{x}, y) + \mathcal{R}_{DI}(\hat{x})\]

where, \(\mathcal{R}_{DI}(\hat{x}) = \mathcal{R}_{prior}(\hat{x}) + \alpha_f \mathcal{R}_{feature}(\hat{x})\).

3.3. Adaptive DeepInversion (ADI)

생성된 이미지의 quality 뿐만 아니라 diversity도 매우 중요하다. 그래서 저자들은 이미지 생성 과정과 student 네트워크 간의 새로운 iterative competition scheme 기반의 개선된 image generation scheme, Adaptive DeepInversion 을 제안함.

메인 아이디어는 student-teacher disagreement를 일으키는 합성 이미지를 만들도록 하는 것임. 즉, student와 teacher간 서로 다른 결과$를 만들어내도록 하는 합성 이미지..

이를 위해서 추가적인 loss term인 $\mathcal{R}_{compete}$를 이미지 생성부분에 더함. (Jensen-Shannon divergence 기반)

\[\mathcal{R}_{compete}(\hat{x}) = 1-JS(p_T(\hat{x}), p_S(\hat{x}))\] \[JS(p_T(\hat{x}), p_S(\hat{x})) = \frac{1}{2}\lgroup KL(p_T(\hat{x}), M) + KL(p_S(\hat{x}), M) \rgroup\]

여기서 $M = \frac{1}{2}\cdot \lgroup p_T(\hat{x}) + p_S(\hat{x})\rgroup$ 이고 이는 다시 teacher와 student distribution의 평균을 의미함.

optimization 동안에 이 새로운 term은 teacher는 쉽게 맞추지만 student는 잘 못맞추는 새로운 이미지들을 만들게 함.

image

해당 term이 추가되면서 regularization term은 아래와 같이 변경된다.

\[\mathcal{R}_{ADI}(\hat{x}) = \mathcal{R}_{DI}(\hat{x}) + \alpha_c\mathcal{R}_{compete}(\hat{x})\]

3.4 DeepInversion vs. Adaptive DeepInversion

DeepInversion의 경우, 어느 CNN classifier에도 적용이 가능한 generic한 메서드라고 할 수 있음. Knowledge distillation에서 knowledge transfer를 시작하기 위해 teacher가 주어졌을 때, 대량의 이미지들을 one-time 합성을 가능하게 함.

반면, Adaptive DeepInversion의 경우, image diversity를 위해 student가 loop에 필요함.

[Note!]
모든 실험에서 noisy initial pixel들은 평균이 0이고
표준편차가 1인 가우시안 노이즈로부터 i.i.d.하게 초기화 됨.

4. Experiments

image

CIFAR10 합성 이미지 image

ImageNet Knowledge transfer 결과 image

5. Discussion 및 사견

Limitations

  1. Image synthesis time : 만들어내는데 엄청 오래걸림. : V100 한장짜리 쓰면 ResNet50 기준 2800시간 걸림 (116.66666667일..?) : 128 지피유 써야 22시간임. : 그나마 multi-resolution scheme 을 사용하면 10.7배 정도 빨라짐.
  2. Image color and background similarity : 배경이 너무 단순하게 나옴 : 모든 이미지 픽셀들의 초기값을 동일한 가우시안 분포 (평균0, 분산1)에서 뽑아냈기 때문에 unimodal behavior 를 야기할 수 있음.
  3. Continual learning class similarity : CL 과정에서 서로 다르게 생긴 데이터셋들에만 좀 좋게 작동하는 것을 확인함. : subset과 같은 완전 비슷한 도메인을 가진 경우에는 성능이 좋지 않았음.

사견

생각보다 학습이미지의 추출이 깔끔하게 잘 된 것을 볼 수 있음.
일단은 서베이를 위하여 읽은 논문이기 때문에 적당히 슥 읽고 넘어가는 중…

Comments