SlideShare a Scribd company logo
1 of 62
Download to read offline
김정훈 & 박진우 from J.MARPLE / Daejeon Learning Day / 2020.09.02
네트워크 경량화 이모저모
왕초보의 경량화 대회 출전기
발표자 소개
김정훈
역할: 발표, 질의응답
https://github.com/Hoonyyhoon
박진우
역할: 질의응답
https://github.com/Curt-Park
계기
네트워크 경량화
네트워크 경량화
네트워크의 “정확도”를 높게 유지하며 “연산속도”를 올리거나 “크기”를 줄이는 것.
네트워크 경량화의 종류
1. Efficient Architecture Design: 효율이 높은 아키텍쳐를 설계
2. Network Pruning: 중요도가 낮은 파라미터를 제거
3. Network Quantization: 파라미터를 좀 더 작은 크기의 타입으로 표현
4. Knowledge Distillation: 학습된 큰 네트워크를 작은 네트워크 학습에 사용
5. Network Compile: 바이너리 형태로 네트워크를 변환
6. Matrix Decomposition: 네트워크의 행렬 연산을 더 작은 행렬 연산으로 변환
…
너무 많다.
시간이 없다.
대회까지는 단 두 달…
기존 대회 조사
답변
Lower Power Image Recognition Challenge (LPIRC)
CVPR에서 매년 열리는 경량화 대회
•2019년 대회 내용
- https://ieeexplore.ieee.org/document/8693826
•실제 장비 위에서의 추론 결과를 평가지표로 사용
- 점수: Accuracy (mAP) / Energy (Watt-Hour)
•트랙: Image Classification / Object Detection / 시간 내 모든 데이터 추론
- 1, 2번 트랙은 지정된 라이브러리, 하드웨어만 사용가능
•참가팀들의 주요전략
- 입력 사이즈 낮추기
- Quantization
- 소프트웨어 및 하드웨어 최적화
•2019년 대회 내용
- https://ieeexplore.ieee.org/document/8693826
•실제 장비 위에서의 추론 결과를 평가지표로 사용
- 점수: Accuracy (mAP) / Energy (Watt-Hour)
•트랙: Image Classification / Object Detection / 시간 내 모든 데이터 추론
- 1, 2번 트랙은 지정된 라이브러리, 하드웨어만 사용가능
•참가팀들의 주요전략
- 입력 사이즈 낮추기
- Quantization
- 소프트웨어 및 하드웨어 최적화
Lower Power Image Recognition Challenge (LPIRC)
CVPR에서 매년 열리는 경량화 대회
구현 미공개
MicroNet Challenge
NeurIPS 2019에서 열린 경량화 대회
•대회 내용
- https://micronet-challenge.github.io/
•네트워크의 총 연산횟수, 파라미터의 갯수, 크기를 평가지표로 사용
- 제출한 네트워크는 대회에서 제시한 최소 성능을 만족해야 함
- 베이스라인 네트워크에 대비한 연산횟수, 파라미터 갯수를 비율로 합산하여 점수로 환산
- Quantization을 적용한만큼 연산횟수 및 파라미터 갯수가 줄어든 것으로 계산
- 네트워크의 Sparsity(0이 있는 정도)만큼 연산횟수 및 파라미터 갯수가 줄어든 것으로 계산
•트랙: ImageNet Classification / CIFAR-100 Classification
•대회 내용
- https://micronet-challenge.github.io/
•네트워크의 총 연산횟수, 파라미터의 갯수, 크기를 평가지표로 사용
- 제출한 네트워크는 대회에서 제시한 최소 성능을 만족해야 함
- 베이스라인 네트워크에 대비한 연산횟수, 파라미터 갯수를 비율로 합산하여 점수로 환산
- Quantization을 적용한만큼 연산횟수 및 파라미터 갯수가 줄어든 것으로 계산
- 네트워크의 Sparsity(0이 있는 정도)만큼 연산횟수 및 파라미터 갯수가 줄어든 것으로 계산
•트랙: ImageNet Classification / CIFAR-100 Classification
구현 공개
MicroNet Challenge
NeurIPS 2019에서 열린 경량화 대회
MicroNet Challenge
RIAIR (CIFAR-100 Track 1위팀)
0.79M 파라미터의 DenseNet 사용.(ResNet-18: 11.17M)
1. Teacher Network 학습 (300 epochs)
2. Student Network 학습 (300 epochs)
3. Student Network의 Conv Layer를 75% pruning하고 knowledge distillation
4. Conv Layer의 activation을 4-bit로 quantization하고 knowledge distillation
5. Conv Layer의 가중치를 4-bit로 quantization한 뒤, knowledge distillation
6. FC Layer를 50% pruning하고 knowledge distillation
7. FC Layer의 가중치를 4-bit로 quantization한 뒤, knowledge distillation
https://github.com/wps712/MicroNetChallenge/tree/cifar100
MicroNet Challenge
KAIST AI (CIFAR-100 Track 2위팀)
MobileNet-v3의 축소판 네트워크를 정의하고 MicroNet이라 명명 (0.75M)
1. 네트워크 학습 (600 epochs)
2. 네트워크 가중치를 45%까지 pruning한 뒤, 다시 학습 (600 epochs)
3. 네트워크 가중치를 65%까지 pruning한 뒤, 다시 학습 (600 epochs)
ㅋ
https://github.com/Kthyeon/micronet_neurips_challenge
MicroNet Challenge
• MixNet / EfficientNet / MobileNet-v2 or v3를 주로 사용
• One-Shot Pruning보다는 Iterative Pruning을 이용
• Quantization 또한 점진적으로(Iterative) 적용하는 경우가 많음
• Pruning과 Quantization을 한 뒤, fine-tuning 또는 재학습 과정에서
Knowledge Distillation을 흔히 사용
• Learning Rate Scheduler로 Cosine Annealing이 많이 이용
• Regularization 전략을 적극적으로 이용
상위팀 전략 요약
MicroNet Challenge
상위팀 전략 요약 (오늘 다뤄볼 내용)
• MixNet / EfficientNet / MobileNet-v2 or v3를 주로 사용
• One-Shot Pruning보다는 Iterative Pruning을 이용
• Quantization 또한 점진적으로(Iterative) 적용하는 경우가 많음
• Pruning과 Quantization을 한 뒤, fine-tuning 또는 재학습 과정에서
Knowledge Distillation을 흔히 사용
• Learning Rate Scheduler로 Cosine Annealing이 많이 이용
• Regularization 전략을 적극적으로 이용
Efficient Architectures
Efficient Architectures
높은 효율의 네트워크 아키텍쳐 설계
Efficient Architectures
MobileNet-v1
• Normal Convolution
Howard et al. “MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications” ArXiv 2017
Image is from https://towardsdatascience.com/a-basic-introduction-to-separable-convolutions-b99ec3102728
DI × DI × M DO × DO × N
연산량: DK × DK × M × N × DI × DI
(DK × DK × M) × N
Efficient Architectures
MobileNet-v1
• Depth-wise Separable Convolution
연산량: DK × DK × M × DI × DI + M × N × DO × DO
Howard et al. “MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications” ArXiv 2017
Image is from https://towardsdatascience.com/a-basic-introduction-to-separable-convolutions-b99ec3102728
DI × DI × M DO × DO × M(DK × DK × 1) × M (1 × 1 × M) × N DO × DO × NDO × DO × M
• Inverted Residual Block
Sandler et al. “MobileNetV2: Inverted Residuals and Linear Bottlenecks” ArXiv 2018
Efficient Architectures
MobileNet-v2
• Block-wise Search (MnasNet) / Layer-wise Search (NetAdapt) / Efficient Last Stage
Howard et al. “Searching for MobileNetV3” ArXiv 2019
Efficient Architectures
MobileNet-v2
Efficient Architectures
MobileNet-v3
• Squeeze-and-Excite
Howard et al. “Searching for MobileNetV3” ArXiv 2019
Efficient Architectures
MobileNet-v3
• Hard Swish
Howard et al. “Searching for MobileNetV3” ArXiv 2019
Efficient Architectures
MixNet
• Mixed Depth-wise Convolutional Kernel / Block-wise Search(MnasNet)
Tan et al. “MixConv: Mixed Depthwise Convolutional Kernels” ArXiv 2019
Efficient Architectures
EfficientNet
• 입력 크기 / 너비 / 깊이와 성능이 같은 FLOPS에도 각 scaling factor에 따라 달라짐에 주목
• MnasNet과 유사한 베이스라인 네트워크(B0)를 정의한 뒤, 로 가정하고 아래의
최적화를 수행하여 탐색
• 를 일정 비율로 증가시키며 여러 형태의 네트워크를 도출 (B1~B7)
ϕ = 1
α, β, γ
ϕ
Tan et al. “EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks” ArXiv 2019
이 제약조건에 의해
Total FLOPS가 대략 만큼 증가2ϕ
Efficient Architectures
더 볼만한 논문들
• Tan et al. “MnasNet: Platform-Aware Neural Architecture Search for Mobile” ArXiv
2018
• Xie et al. “Self-training with Noisy Student improves ImageNet classification” ArXiv
2019
• Xie et al. “Adversarial Examples Improve Image Recognition” ArXiv 2019
• Touvron et al. “Fixing the train-test resolution discrepancy: FixEfficientNet” ArXiv
2020
Network Pruning
Network Pruning
중요도가 낮은 파라미터를 제거하는 것
Network Pruning
소분류
• Structured Pruning: 파라미터를 그룹 단위로 pruning하는 기법들을 총칭. 여기서의 그룹
은 channel / filter, layer 등이 될 수 있다. Dense computation에 최적화된 소프트웨어 또는
하드웨어에 적합한 기법.
• Unstructured Pruning: 파라미터 각각을 독립적으로 pruning하는 기법. 즉, pruning을 수
행할 수록 네트워크 내부의 행렬이 점차 희소(sparse)해진다. Structured Pruning과 달리
sparse computation에 최적화된 소프트웨어 또는 하드웨어에 적합한 기법.
Frankle et al. “WHAT IS THE STATE OF NEURAL NETWORK PRUNING?” ArXiv 2020
Unstructured Pruning
The Lottery Ticket Hypothesis (LTH)
Frankle et al. “The Lottery Ticket Hypothesis: Finding Sparse, Trainable Neural Networks” ICLR 2019
• 네트워크의 초기 파라미터 값을 매 pruning iteration 마다 파라미터 초기화에 사용
1. 네트워크를 임의로 초기화 (where )
2. 네트워크를 j번 학습하여 파라미터 를 도출
3. 파라미터 를 p% 만큼 pruning하여 마스크 을 생성
4. 파라미터를 로 초기화하고 이를 당첨된 복권(winning ticket)이라 지칭
5. 2~4를 반복
f(x; θ0) θ0 ∼ Dθ
θj
θj m
θ0 f(x; m ⊙ θ0)
Unstructured Pruning
The Lottery Ticket Hypothesis (LTH)
Frankle et al. “The Lottery Ticket Hypothesis: Finding Sparse, Trainable Neural Networks” ArXiv 2018
•간단한 아이디어이지만 매우 좋은 성능을 보임 (3.6%의 가중치만 사용하면서도 성능을 유지)
•고착화 되어 있던 Pruning -> Fine-Tuning 방식의 틀을 깨고 새로운 패러다임을 제시
Unstructured Pruning
Stabilizing the Lottery Ticket Hypothesis (Weight Rewinding)
• LTH는 데이터셋 또는 네트워크의 크기가 커졌을 때 불안정한 모습을 보임
• k번째 학습한 파라미터로 네트워크를 초기화하면 학습이 안정화 됨을 보임 (Weight Rewinding)
• 논문에서는 총 iteration의 0.1% ~ 7% 정도의 지점을 rewinding point로 언급
Frankle et al. “Stabilizing the Lottery Ticket Hypothesis∗” ArXiv 2019
Unstructured Pruning
COMPARING REWINDING AND FINE-TUNING IN NEURAL NETWORK PRUNING (Learning Rate Rewinding)
• Fine-tuning처럼 학습한 파라미터 값을 그대로 상속받되, Learning Rate Schedule을 특정 시점
(k)으로 rewinding하는 전략을 제안하고 이를 Learning Rate Rewinding이라 명명
• 저자들은 k=0일때 대체로 좋은 성능을 보이므로 k=0으로 두고 따로 튜닝하지 않는 것을 제안
Renda et al. “COMPARING REWINDING AND FINE-TUNING IN NEURAL NETWORK PRUNING” ArXiv 2020
Unstructured Pruning
Example Configuration: LTH
https://github.com/j-marple-dev/model_compression
config = {
"EPOCHS": 300,
"N_PRUNING_ITER": 10,
"PRUNE_METHOD": "LotteryTicketHypothesis",
"PRUNE_PARAMS": dict(
PRUNE_AMOUNT=0.2, STORE_PARAM_BEFORE=0, TRAIN_START_FROM=0
),
}
Unstructured Pruning
Example Configuration: Weight Rewinding
https://github.com/j-marple-dev/model_compression
config = {
"EPOCHS": 300,
"N_PRUNING_ITER": 10,
"PRUNE_METHOD": "WeightRewinding",
"PRUNE_PARAMS": dict(
PRUNE_AMOUNT=0.2, STORE_PARAM_BEFORE=15, TRAIN_START_FROM=15
),
}
Rewinding Point
Unstructured Pruning
Example Configuration: Learning Rate Rewinding
https://github.com/j-marple-dev/model_compression
config = {
"EPOCHS": 300,
"N_PRUNING_ITER": 10,
"PRUNE_METHOD": "LearningRateRewinding",
"PRUNE_PARAMS": dict(
PRUNE_AMOUNT=0.2, STORE_PARAM_BEFORE=300, TRAIN_START_FROM=0
),
}
K = 0
Structured Pruning
Channel-Wise Magnitude Based Pruning
• 네트워크를 학습한 뒤, Convolution Layer 각 filter의 크기(magnitude)를 구하여
그 크기가 작은 p%의 채널을 pruning하는 방법
1. 모든 convolution filter의 각 가중치에 L1-norm을 취한 것을 합
2. 1에서 구한 값을 기준으로 filter들을 정렬
3. 정렬된 filter 중 값이 작은 p%를 제거
4. 3으로 인해 제거되는 feature map을 염두하여 다음 layer의 filter 차원을 축소
Li et al. “Pruning Filters for Efficient ConvNets” ArXiv 2016
Structured Pruning
Learning Efficient Convolutional Networks through Network Slimming
• 각 convolution layer batchnorm의 scaling parameter 에 L1-norm을 regularizer로 사용
• L1-regularizer의 효과로 가 0에 가까워지는 채널은 점차 비활성화
• 의 값을 기준으로 정렬하여 이 중 작은 p%의 채널을 pruning
γ
γ
γ
Liu et al. “Learning Efficient Convolutional Networks through Network Slimming” ArXiv 2017
Network Pruning
더 볼만한 논문들
• Yang et al. “NetAdapt: Platform-Aware Neural Network Adaptation for Mobile
Applications” ArXiv 2018
• Liu et al. “RETHINKING THE VALUE OF NETWORK PRUNING” ArXiv 2018
• Morcos et al. “One ticket to win them all: generalizing lottery ticket initializations across
datasets and optimizers” ArXiv 2019
• Frankle et al. “Linear Mode Connectivity and the Lottery Ticket Hypothesis” ArXiv 2019
• Frankle et al. “WHAT IS THE STATE OF NEURAL NETWORK PRUNING?” ArXiv 2020
Network Quantization
Network Quantization
파라미터의 값을 좀 더 작은 크기의 타입으로 표현하는 것
Quantizer Design
Uniform Affine Quantizer
• Uniform Affine Quantizer를 이용하여 ( , )의 값의 범위를 가진 floating point
변수를 (0, − 1)의 범위를 가진 integer 변수로 quantization하면 다음과 같다.
xmin xmax
Nlevels
Krishnamoorthi et al. “Quantizing deep convolutional networks for efficient inference: A whitepaper” ArXiv 2018
: Scale

: zero point
Δ
z
Quantizer Design
Uniform Symmetric Quantizer
•Zero-point가 0이며, floating point 변수를 signed integer로 매핑한다.
Krishnamoorthi et al. “Quantizing deep convolutional networks for efficient inference: A whitepaper” ArXiv 2018
: ScaleΔ
Network Quantization
소분류
• Post Training Quantization: 별도의 학습 없이 weight 또는 weight와 activation을
quantization하는 방법. 데이터의 사용이 제한적인 경우에 사용이 용이하며 또한 절차가 간
단한 편. 아래 표는 32-bit floating point 변수를 8-bit로 quantization 했을 때의 성능손실
을 보여준다.
Krishnamoorthi et al. “Quantizing deep convolutional networks for efficient inference: A whitepaper” ArXiv 2018
Network Quantization
소분류
• Quantization Aware Training (QAT): Weight 또는 activation이 floating 타입이지만 이
보다 더 작은 타입을 모방하도록(fake-quantized) 더 작은 범위로 값을 사상(mapping)한다.
이때의 weight 또는 activation은 floating type이기 때문에 학습이 가능하다. 아래 표를 통해
Post Training Quantization 보다 QAT가 좀 더 높은 성능을 보임을 확인할 수 있다.
Krishnamoorthi et al. “Quantizing deep convolutional networks for efficient inference: A whitepaper” ArXiv 2018
Network Pruning
더 볼만한 자료들
• Neural Network Distiller, https://nervanasystems.github.io/distiller/index.html
• Microsoft’s NNI, https://nni.readthedocs.io/en/latest/
• Qualcomm’s AIMET, https://github.com/quic/aimet
• PyTorch Docs, https://pytorch.org/docs/stable/quantization.html
• PyTorch Tutorial, https://pytorch.org/tutorials/advanced/static_quantization_tutorial.html
• PyTorch Quantization Example: https://github.com/pytorch/vision/blob/master/torchvision/
models/quantization/mobilenet.py
Knowledge Distillation
Knowledge Distillation
학습된 큰 네트워크(Teacher)를 작은 네트워크(Student)의 학습 보조로 사용하는 방법
Knowledge Distillation
Distilling the Knowledge in a Neural Network (a.k.a. Hinton Loss)
• Student network와 ground truth label의 cross-entropy + teacher network와 student
network의 inference 결과에 대한 KLD loss로 정의
• 는 large teacher network의 출력을 smoothing(flat) 하는 역할을 한다.(Soft Target)
• 는 두 loss의 균형을 조절하는 파라미터다.
T
α
Hinton et al. “Distilling the Knowledge in a Neural Network” ArXiv 2015
Knowledge Distillation
Feature Distillation Methods
• Teacher network와 student network의 출력을 이용하는 것과 달리 feature distillation은
네트워크 feature 정보를 이용하여 distillation loss를 정의.
• Ruffy et al. (2019), Tian et al. (2020)은 SOTA임을 주장하는 많은 논문들의 실제 재현성
능이 HintonLoss 를 크게 상회하지 못하였고, 특히 feature distillation methods들은 성능 재
현이 매우 어렵다고 밝혔다.
Tian et al. “Contrastive Representation Distillation” ICLR 2020
https://github.com/HobbitLong/RepDistiller
Ruffy et al. “The State Of Knowledge Distillation For Classification Tasks” ArXiv 2019
https://github.com/karanchahal/distiller
HintonLoss
대회출전
좋은 결과
코로나 ㅠㅜ
대회 참가에 사용한 코드 저장소를 공개합니다!
https://github.com/j-marple-dev/model_compression
알찬 내용이 가득
• Architecture: MixNet / Fast DenseNet
• Augmentation: AutoAugment / RandAugment / CutMix / CutOut
• Loss: Cross Entropy Loss + Label Smoothing / Hinton Loss
• LR Scheduler: Cosine Annealing + Initial Warmup
• Unstructured Pruning: LTH / Weight Rewinding / LR Rewinding
• Structured Pruning: Magnitude Pruning / Network Slimming / Mag + Slimming
• Channel-Wise Pruned Model Shrinker (Experimental)
• Quantization: Post Training Quantization / Quantization Aware Training
궁금하신 점은 저장소의 issue에 남겨주세요!
감사합니다

More Related Content

What's hot

三次元点群を取り扱うニューラルネットワークのサーベイ
三次元点群を取り扱うニューラルネットワークのサーベイ三次元点群を取り扱うニューラルネットワークのサーベイ
三次元点群を取り扱うニューラルネットワークのサーベイNaoya Chiba
 
CVPR 2015 読み会 "Understanding Deep Image Representations by Inverting Them"
CVPR 2015 読み会 "Understanding Deep Image Representations by Inverting Them"CVPR 2015 読み会 "Understanding Deep Image Representations by Inverting Them"
CVPR 2015 読み会 "Understanding Deep Image Representations by Inverting Them"Hiroharu Kato
 
NVIDIA GPU Cloud の紹介
NVIDIA GPU Cloud の紹介NVIDIA GPU Cloud の紹介
NVIDIA GPU Cloud の紹介NVIDIA Japan
 
DeepPose: Human Pose Estimation via Deep Neural Networks
DeepPose: Human Pose Estimation via Deep Neural NetworksDeepPose: Human Pose Estimation via Deep Neural Networks
DeepPose: Human Pose Estimation via Deep Neural NetworksShunta Saito
 
第8回関西CV・PRML勉強会(Meanshift)
第8回関西CV・PRML勉強会(Meanshift)第8回関西CV・PRML勉強会(Meanshift)
第8回関西CV・PRML勉強会(Meanshift)Yutaka Yamada
 
[DL輪読会]Deep High-Resolution Representation Learning for Human Pose Estimation
[DL輪読会]Deep High-Resolution Representation Learning for Human Pose Estimation[DL輪読会]Deep High-Resolution Representation Learning for Human Pose Estimation
[DL輪読会]Deep High-Resolution Representation Learning for Human Pose EstimationDeep Learning JP
 
【DL輪読会】WIRE: Wavelet Implicit Neural Representations
【DL輪読会】WIRE: Wavelet Implicit Neural Representations【DL輪読会】WIRE: Wavelet Implicit Neural Representations
【DL輪読会】WIRE: Wavelet Implicit Neural RepresentationsDeep Learning JP
 
論文紹介「A Perspective View and Survey of Meta-Learning」
論文紹介「A Perspective View and Survey of Meta-Learning」論文紹介「A Perspective View and Survey of Meta-Learning」
論文紹介「A Perspective View and Survey of Meta-Learning」Kota Matsui
 
グラフデータ分析 入門編
グラフデータ分析 入門編グラフデータ分析 入門編
グラフデータ分析 入門編順也 山口
 
Densely Connected Convolutional Networks
Densely Connected Convolutional NetworksDensely Connected Convolutional Networks
Densely Connected Convolutional Networksharmonylab
 
MLaPP 24章 「マルコフ連鎖モンテカルロ法 (MCMC) による推論」
MLaPP 24章 「マルコフ連鎖モンテカルロ法 (MCMC) による推論」MLaPP 24章 「マルコフ連鎖モンテカルロ法 (MCMC) による推論」
MLaPP 24章 「マルコフ連鎖モンテカルロ法 (MCMC) による推論」moterech
 
Deep Learningによる超解像の進歩
Deep Learningによる超解像の進歩Deep Learningによる超解像の進歩
Deep Learningによる超解像の進歩Hiroto Honda
 
自己教師学習(Self-Supervised Learning)
自己教師学習(Self-Supervised Learning)自己教師学習(Self-Supervised Learning)
自己教師学習(Self-Supervised Learning)cvpaper. challenge
 
20160724_cv_sfm_revisited
20160724_cv_sfm_revisited20160724_cv_sfm_revisited
20160724_cv_sfm_revisitedKyohei Unno
 
[DL輪読会]3D Human Pose Estimation @ CVPR’19 / ICCV’19
[DL輪読会]3D Human Pose Estimation @ CVPR’19 / ICCV’19[DL輪読会]3D Human Pose Estimation @ CVPR’19 / ICCV’19
[DL輪読会]3D Human Pose Estimation @ CVPR’19 / ICCV’19Deep Learning JP
 
[DL輪読会]Neural Ordinary Differential Equations
[DL輪読会]Neural Ordinary Differential Equations[DL輪読会]Neural Ordinary Differential Equations
[DL輪読会]Neural Ordinary Differential EquationsDeep Learning JP
 
Triplet Loss 徹底解説
Triplet Loss 徹底解説Triplet Loss 徹底解説
Triplet Loss 徹底解説tancoro
 

What's hot (20)

三次元点群を取り扱うニューラルネットワークのサーベイ
三次元点群を取り扱うニューラルネットワークのサーベイ三次元点群を取り扱うニューラルネットワークのサーベイ
三次元点群を取り扱うニューラルネットワークのサーベイ
 
CVPR 2015 読み会 "Understanding Deep Image Representations by Inverting Them"
CVPR 2015 読み会 "Understanding Deep Image Representations by Inverting Them"CVPR 2015 読み会 "Understanding Deep Image Representations by Inverting Them"
CVPR 2015 読み会 "Understanding Deep Image Representations by Inverting Them"
 
NVIDIA GPU Cloud の紹介
NVIDIA GPU Cloud の紹介NVIDIA GPU Cloud の紹介
NVIDIA GPU Cloud の紹介
 
DeepPose: Human Pose Estimation via Deep Neural Networks
DeepPose: Human Pose Estimation via Deep Neural NetworksDeepPose: Human Pose Estimation via Deep Neural Networks
DeepPose: Human Pose Estimation via Deep Neural Networks
 
第8回関西CV・PRML勉強会(Meanshift)
第8回関西CV・PRML勉強会(Meanshift)第8回関西CV・PRML勉強会(Meanshift)
第8回関西CV・PRML勉強会(Meanshift)
 
[DL輪読会]Deep High-Resolution Representation Learning for Human Pose Estimation
[DL輪読会]Deep High-Resolution Representation Learning for Human Pose Estimation[DL輪読会]Deep High-Resolution Representation Learning for Human Pose Estimation
[DL輪読会]Deep High-Resolution Representation Learning for Human Pose Estimation
 
【DL輪読会】WIRE: Wavelet Implicit Neural Representations
【DL輪読会】WIRE: Wavelet Implicit Neural Representations【DL輪読会】WIRE: Wavelet Implicit Neural Representations
【DL輪読会】WIRE: Wavelet Implicit Neural Representations
 
Cvpr 2019 pvnet
Cvpr 2019 pvnetCvpr 2019 pvnet
Cvpr 2019 pvnet
 
論文紹介「A Perspective View and Survey of Meta-Learning」
論文紹介「A Perspective View and Survey of Meta-Learning」論文紹介「A Perspective View and Survey of Meta-Learning」
論文紹介「A Perspective View and Survey of Meta-Learning」
 
グラフデータ分析 入門編
グラフデータ分析 入門編グラフデータ分析 入門編
グラフデータ分析 入門編
 
Densely Connected Convolutional Networks
Densely Connected Convolutional NetworksDensely Connected Convolutional Networks
Densely Connected Convolutional Networks
 
MLaPP 24章 「マルコフ連鎖モンテカルロ法 (MCMC) による推論」
MLaPP 24章 「マルコフ連鎖モンテカルロ法 (MCMC) による推論」MLaPP 24章 「マルコフ連鎖モンテカルロ法 (MCMC) による推論」
MLaPP 24章 「マルコフ連鎖モンテカルロ法 (MCMC) による推論」
 
KDD2016勉強会 資料
KDD2016勉強会 資料KDD2016勉強会 資料
KDD2016勉強会 資料
 
Deep Learningによる超解像の進歩
Deep Learningによる超解像の進歩Deep Learningによる超解像の進歩
Deep Learningによる超解像の進歩
 
ResNetの仕組み
ResNetの仕組みResNetの仕組み
ResNetの仕組み
 
自己教師学習(Self-Supervised Learning)
自己教師学習(Self-Supervised Learning)自己教師学習(Self-Supervised Learning)
自己教師学習(Self-Supervised Learning)
 
20160724_cv_sfm_revisited
20160724_cv_sfm_revisited20160724_cv_sfm_revisited
20160724_cv_sfm_revisited
 
[DL輪読会]3D Human Pose Estimation @ CVPR’19 / ICCV’19
[DL輪読会]3D Human Pose Estimation @ CVPR’19 / ICCV’19[DL輪読会]3D Human Pose Estimation @ CVPR’19 / ICCV’19
[DL輪読会]3D Human Pose Estimation @ CVPR’19 / ICCV’19
 
[DL輪読会]Neural Ordinary Differential Equations
[DL輪読会]Neural Ordinary Differential Equations[DL輪読会]Neural Ordinary Differential Equations
[DL輪読会]Neural Ordinary Differential Equations
 
Triplet Loss 徹底解説
Triplet Loss 徹底解説Triplet Loss 徹底解説
Triplet Loss 徹底解説
 

Similar to 네트워크 경량화 이모저모 @ 2020 DLD

Designing more efficient convolution neural network
Designing more efficient convolution neural networkDesigning more efficient convolution neural network
Designing more efficient convolution neural networkNAVER Engineering
 
Designing more efficient convolution neural network
Designing more efficient convolution neural networkDesigning more efficient convolution neural network
Designing more efficient convolution neural networkDongyi Kim
 
Deep Learning & Convolutional Neural Network
Deep Learning & Convolutional Neural NetworkDeep Learning & Convolutional Neural Network
Deep Learning & Convolutional Neural Networkagdatalab
 
Basics of deep learning_imcloud
Basics of deep learning_imcloudBasics of deep learning_imcloud
Basics of deep learning_imcloudimcloud
 
딥러닝 논문읽기 efficient netv2 논문리뷰
딥러닝 논문읽기 efficient netv2  논문리뷰딥러닝 논문읽기 efficient netv2  논문리뷰
딥러닝 논문읽기 efficient netv2 논문리뷰taeseon ryu
 
스마트폰 위의 딥러닝
스마트폰 위의 딥러닝스마트폰 위의 딥러닝
스마트폰 위의 딥러닝NAVER Engineering
 
[한국어] Neural Architecture Search with Reinforcement Learning
[한국어] Neural Architecture Search with Reinforcement Learning[한국어] Neural Architecture Search with Reinforcement Learning
[한국어] Neural Architecture Search with Reinforcement LearningKiho Suh
 
PR-313 Training BatchNorm and Only BatchNorm: On the Expressive Power of Rand...
PR-313 Training BatchNorm and Only BatchNorm: On the Expressive Power of Rand...PR-313 Training BatchNorm and Only BatchNorm: On the Expressive Power of Rand...
PR-313 Training BatchNorm and Only BatchNorm: On the Expressive Power of Rand...Sunghoon Joo
 
"Learning transferable architectures for scalable image recognition" Paper Re...
"Learning transferable architectures for scalable image recognition" Paper Re..."Learning transferable architectures for scalable image recognition" Paper Re...
"Learning transferable architectures for scalable image recognition" Paper Re...LEE HOSEONG
 
작고 빠른 딥러닝 그리고 Edge computing
작고 빠른 딥러닝 그리고 Edge computing작고 빠른 딥러닝 그리고 Edge computing
작고 빠른 딥러닝 그리고 Edge computingStellaSeoYeonYang
 
위성관측 데이터 활용 강수량 산출 AI 경진대회 1위 수상작
위성관측 데이터 활용 강수량 산출 AI 경진대회 1위 수상작위성관측 데이터 활용 강수량 산출 AI 경진대회 1위 수상작
위성관측 데이터 활용 강수량 산출 AI 경진대회 1위 수상작DACON AI 데이콘
 
180624 mobile visionnet_baeksucon_jwkang_pub
180624 mobile visionnet_baeksucon_jwkang_pub180624 mobile visionnet_baeksucon_jwkang_pub
180624 mobile visionnet_baeksucon_jwkang_pubJaewook. Kang
 
K means 알고리즘을 이용한 영화배우 클러스터링
K means 알고리즘을 이용한 영화배우 클러스터링K means 알고리즘을 이용한 영화배우 클러스터링
K means 알고리즘을 이용한 영화배우 클러스터링Edward Yoon
 
History of Vision AI
History of Vision AIHistory of Vision AI
History of Vision AITae Young Lee
 
[paper review] 손규빈 - Eye in the sky & 3D human pose estimation in video with ...
[paper review] 손규빈 - Eye in the sky & 3D human pose estimation in video with ...[paper review] 손규빈 - Eye in the sky & 3D human pose estimation in video with ...
[paper review] 손규빈 - Eye in the sky & 3D human pose estimation in video with ...Gyubin Son
 
텐서플로우 2.0 튜토리얼 - CNN
텐서플로우 2.0 튜토리얼 - CNN텐서플로우 2.0 튜토리얼 - CNN
텐서플로우 2.0 튜토리얼 - CNNHwanhee Kim
 
PR-203: Class-Balanced Loss Based on Effective Number of Samples
PR-203: Class-Balanced Loss Based on Effective Number of SamplesPR-203: Class-Balanced Loss Based on Effective Number of Samples
PR-203: Class-Balanced Loss Based on Effective Number of SamplesSunghoon Joo
 

Similar to 네트워크 경량화 이모저모 @ 2020 DLD (20)

Net adapt
Net adaptNet adapt
Net adapt
 
Designing more efficient convolution neural network
Designing more efficient convolution neural networkDesigning more efficient convolution neural network
Designing more efficient convolution neural network
 
Designing more efficient convolution neural network
Designing more efficient convolution neural networkDesigning more efficient convolution neural network
Designing more efficient convolution neural network
 
Deep Learning & Convolutional Neural Network
Deep Learning & Convolutional Neural NetworkDeep Learning & Convolutional Neural Network
Deep Learning & Convolutional Neural Network
 
Basics of deep learning_imcloud
Basics of deep learning_imcloudBasics of deep learning_imcloud
Basics of deep learning_imcloud
 
딥러닝 논문읽기 efficient netv2 논문리뷰
딥러닝 논문읽기 efficient netv2  논문리뷰딥러닝 논문읽기 efficient netv2  논문리뷰
딥러닝 논문읽기 efficient netv2 논문리뷰
 
스마트폰 위의 딥러닝
스마트폰 위의 딥러닝스마트폰 위의 딥러닝
스마트폰 위의 딥러닝
 
AUTOML
AUTOMLAUTOML
AUTOML
 
Automl
AutomlAutoml
Automl
 
[한국어] Neural Architecture Search with Reinforcement Learning
[한국어] Neural Architecture Search with Reinforcement Learning[한국어] Neural Architecture Search with Reinforcement Learning
[한국어] Neural Architecture Search with Reinforcement Learning
 
PR-313 Training BatchNorm and Only BatchNorm: On the Expressive Power of Rand...
PR-313 Training BatchNorm and Only BatchNorm: On the Expressive Power of Rand...PR-313 Training BatchNorm and Only BatchNorm: On the Expressive Power of Rand...
PR-313 Training BatchNorm and Only BatchNorm: On the Expressive Power of Rand...
 
"Learning transferable architectures for scalable image recognition" Paper Re...
"Learning transferable architectures for scalable image recognition" Paper Re..."Learning transferable architectures for scalable image recognition" Paper Re...
"Learning transferable architectures for scalable image recognition" Paper Re...
 
작고 빠른 딥러닝 그리고 Edge computing
작고 빠른 딥러닝 그리고 Edge computing작고 빠른 딥러닝 그리고 Edge computing
작고 빠른 딥러닝 그리고 Edge computing
 
위성관측 데이터 활용 강수량 산출 AI 경진대회 1위 수상작
위성관측 데이터 활용 강수량 산출 AI 경진대회 1위 수상작위성관측 데이터 활용 강수량 산출 AI 경진대회 1위 수상작
위성관측 데이터 활용 강수량 산출 AI 경진대회 1위 수상작
 
180624 mobile visionnet_baeksucon_jwkang_pub
180624 mobile visionnet_baeksucon_jwkang_pub180624 mobile visionnet_baeksucon_jwkang_pub
180624 mobile visionnet_baeksucon_jwkang_pub
 
K means 알고리즘을 이용한 영화배우 클러스터링
K means 알고리즘을 이용한 영화배우 클러스터링K means 알고리즘을 이용한 영화배우 클러스터링
K means 알고리즘을 이용한 영화배우 클러스터링
 
History of Vision AI
History of Vision AIHistory of Vision AI
History of Vision AI
 
[paper review] 손규빈 - Eye in the sky & 3D human pose estimation in video with ...
[paper review] 손규빈 - Eye in the sky & 3D human pose estimation in video with ...[paper review] 손규빈 - Eye in the sky & 3D human pose estimation in video with ...
[paper review] 손규빈 - Eye in the sky & 3D human pose estimation in video with ...
 
텐서플로우 2.0 튜토리얼 - CNN
텐서플로우 2.0 튜토리얼 - CNN텐서플로우 2.0 튜토리얼 - CNN
텐서플로우 2.0 튜토리얼 - CNN
 
PR-203: Class-Balanced Loss Based on Effective Number of Samples
PR-203: Class-Balanced Loss Based on Effective Number of SamplesPR-203: Class-Balanced Loss Based on Effective Number of Samples
PR-203: Class-Balanced Loss Based on Effective Number of Samples
 

네트워크 경량화 이모저모 @ 2020 DLD

  • 1. 김정훈 & 박진우 from J.MARPLE / Daejeon Learning Day / 2020.09.02 네트워크 경량화 이모저모 왕초보의 경량화 대회 출전기
  • 5.
  • 6.
  • 8. 네트워크 경량화 네트워크의 “정확도”를 높게 유지하며 “연산속도”를 올리거나 “크기”를 줄이는 것.
  • 9. 네트워크 경량화의 종류 1. Efficient Architecture Design: 효율이 높은 아키텍쳐를 설계 2. Network Pruning: 중요도가 낮은 파라미터를 제거 3. Network Quantization: 파라미터를 좀 더 작은 크기의 타입으로 표현 4. Knowledge Distillation: 학습된 큰 네트워크를 작은 네트워크 학습에 사용 5. Network Compile: 바이너리 형태로 네트워크를 변환 6. Matrix Decomposition: 네트워크의 행렬 연산을 더 작은 행렬 연산으로 변환 …
  • 12. Lower Power Image Recognition Challenge (LPIRC) CVPR에서 매년 열리는 경량화 대회 •2019년 대회 내용 - https://ieeexplore.ieee.org/document/8693826 •실제 장비 위에서의 추론 결과를 평가지표로 사용 - 점수: Accuracy (mAP) / Energy (Watt-Hour) •트랙: Image Classification / Object Detection / 시간 내 모든 데이터 추론 - 1, 2번 트랙은 지정된 라이브러리, 하드웨어만 사용가능 •참가팀들의 주요전략 - 입력 사이즈 낮추기 - Quantization - 소프트웨어 및 하드웨어 최적화
  • 13. •2019년 대회 내용 - https://ieeexplore.ieee.org/document/8693826 •실제 장비 위에서의 추론 결과를 평가지표로 사용 - 점수: Accuracy (mAP) / Energy (Watt-Hour) •트랙: Image Classification / Object Detection / 시간 내 모든 데이터 추론 - 1, 2번 트랙은 지정된 라이브러리, 하드웨어만 사용가능 •참가팀들의 주요전략 - 입력 사이즈 낮추기 - Quantization - 소프트웨어 및 하드웨어 최적화 Lower Power Image Recognition Challenge (LPIRC) CVPR에서 매년 열리는 경량화 대회 구현 미공개
  • 14. MicroNet Challenge NeurIPS 2019에서 열린 경량화 대회 •대회 내용 - https://micronet-challenge.github.io/ •네트워크의 총 연산횟수, 파라미터의 갯수, 크기를 평가지표로 사용 - 제출한 네트워크는 대회에서 제시한 최소 성능을 만족해야 함 - 베이스라인 네트워크에 대비한 연산횟수, 파라미터 갯수를 비율로 합산하여 점수로 환산 - Quantization을 적용한만큼 연산횟수 및 파라미터 갯수가 줄어든 것으로 계산 - 네트워크의 Sparsity(0이 있는 정도)만큼 연산횟수 및 파라미터 갯수가 줄어든 것으로 계산 •트랙: ImageNet Classification / CIFAR-100 Classification
  • 15. •대회 내용 - https://micronet-challenge.github.io/ •네트워크의 총 연산횟수, 파라미터의 갯수, 크기를 평가지표로 사용 - 제출한 네트워크는 대회에서 제시한 최소 성능을 만족해야 함 - 베이스라인 네트워크에 대비한 연산횟수, 파라미터 갯수를 비율로 합산하여 점수로 환산 - Quantization을 적용한만큼 연산횟수 및 파라미터 갯수가 줄어든 것으로 계산 - 네트워크의 Sparsity(0이 있는 정도)만큼 연산횟수 및 파라미터 갯수가 줄어든 것으로 계산 •트랙: ImageNet Classification / CIFAR-100 Classification 구현 공개 MicroNet Challenge NeurIPS 2019에서 열린 경량화 대회
  • 16. MicroNet Challenge RIAIR (CIFAR-100 Track 1위팀) 0.79M 파라미터의 DenseNet 사용.(ResNet-18: 11.17M) 1. Teacher Network 학습 (300 epochs) 2. Student Network 학습 (300 epochs) 3. Student Network의 Conv Layer를 75% pruning하고 knowledge distillation 4. Conv Layer의 activation을 4-bit로 quantization하고 knowledge distillation 5. Conv Layer의 가중치를 4-bit로 quantization한 뒤, knowledge distillation 6. FC Layer를 50% pruning하고 knowledge distillation 7. FC Layer의 가중치를 4-bit로 quantization한 뒤, knowledge distillation https://github.com/wps712/MicroNetChallenge/tree/cifar100
  • 17. MicroNet Challenge KAIST AI (CIFAR-100 Track 2위팀) MobileNet-v3의 축소판 네트워크를 정의하고 MicroNet이라 명명 (0.75M) 1. 네트워크 학습 (600 epochs) 2. 네트워크 가중치를 45%까지 pruning한 뒤, 다시 학습 (600 epochs) 3. 네트워크 가중치를 65%까지 pruning한 뒤, 다시 학습 (600 epochs) ㅋ https://github.com/Kthyeon/micronet_neurips_challenge
  • 18. MicroNet Challenge • MixNet / EfficientNet / MobileNet-v2 or v3를 주로 사용 • One-Shot Pruning보다는 Iterative Pruning을 이용 • Quantization 또한 점진적으로(Iterative) 적용하는 경우가 많음 • Pruning과 Quantization을 한 뒤, fine-tuning 또는 재학습 과정에서 Knowledge Distillation을 흔히 사용 • Learning Rate Scheduler로 Cosine Annealing이 많이 이용 • Regularization 전략을 적극적으로 이용 상위팀 전략 요약
  • 19. MicroNet Challenge 상위팀 전략 요약 (오늘 다뤄볼 내용) • MixNet / EfficientNet / MobileNet-v2 or v3를 주로 사용 • One-Shot Pruning보다는 Iterative Pruning을 이용 • Quantization 또한 점진적으로(Iterative) 적용하는 경우가 많음 • Pruning과 Quantization을 한 뒤, fine-tuning 또는 재학습 과정에서 Knowledge Distillation을 흔히 사용 • Learning Rate Scheduler로 Cosine Annealing이 많이 이용 • Regularization 전략을 적극적으로 이용
  • 21. Efficient Architectures 높은 효율의 네트워크 아키텍쳐 설계
  • 22. Efficient Architectures MobileNet-v1 • Normal Convolution Howard et al. “MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications” ArXiv 2017 Image is from https://towardsdatascience.com/a-basic-introduction-to-separable-convolutions-b99ec3102728 DI × DI × M DO × DO × N 연산량: DK × DK × M × N × DI × DI (DK × DK × M) × N
  • 23. Efficient Architectures MobileNet-v1 • Depth-wise Separable Convolution 연산량: DK × DK × M × DI × DI + M × N × DO × DO Howard et al. “MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications” ArXiv 2017 Image is from https://towardsdatascience.com/a-basic-introduction-to-separable-convolutions-b99ec3102728 DI × DI × M DO × DO × M(DK × DK × 1) × M (1 × 1 × M) × N DO × DO × NDO × DO × M
  • 24. • Inverted Residual Block Sandler et al. “MobileNetV2: Inverted Residuals and Linear Bottlenecks” ArXiv 2018 Efficient Architectures MobileNet-v2
  • 25. • Block-wise Search (MnasNet) / Layer-wise Search (NetAdapt) / Efficient Last Stage Howard et al. “Searching for MobileNetV3” ArXiv 2019 Efficient Architectures MobileNet-v2
  • 26. Efficient Architectures MobileNet-v3 • Squeeze-and-Excite Howard et al. “Searching for MobileNetV3” ArXiv 2019
  • 27. Efficient Architectures MobileNet-v3 • Hard Swish Howard et al. “Searching for MobileNetV3” ArXiv 2019
  • 28. Efficient Architectures MixNet • Mixed Depth-wise Convolutional Kernel / Block-wise Search(MnasNet) Tan et al. “MixConv: Mixed Depthwise Convolutional Kernels” ArXiv 2019
  • 29. Efficient Architectures EfficientNet • 입력 크기 / 너비 / 깊이와 성능이 같은 FLOPS에도 각 scaling factor에 따라 달라짐에 주목 • MnasNet과 유사한 베이스라인 네트워크(B0)를 정의한 뒤, 로 가정하고 아래의 최적화를 수행하여 탐색 • 를 일정 비율로 증가시키며 여러 형태의 네트워크를 도출 (B1~B7) ϕ = 1 α, β, γ ϕ Tan et al. “EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks” ArXiv 2019 이 제약조건에 의해 Total FLOPS가 대략 만큼 증가2ϕ
  • 30. Efficient Architectures 더 볼만한 논문들 • Tan et al. “MnasNet: Platform-Aware Neural Architecture Search for Mobile” ArXiv 2018 • Xie et al. “Self-training with Noisy Student improves ImageNet classification” ArXiv 2019 • Xie et al. “Adversarial Examples Improve Image Recognition” ArXiv 2019 • Touvron et al. “Fixing the train-test resolution discrepancy: FixEfficientNet” ArXiv 2020
  • 32. Network Pruning 중요도가 낮은 파라미터를 제거하는 것
  • 33. Network Pruning 소분류 • Structured Pruning: 파라미터를 그룹 단위로 pruning하는 기법들을 총칭. 여기서의 그룹 은 channel / filter, layer 등이 될 수 있다. Dense computation에 최적화된 소프트웨어 또는 하드웨어에 적합한 기법. • Unstructured Pruning: 파라미터 각각을 독립적으로 pruning하는 기법. 즉, pruning을 수 행할 수록 네트워크 내부의 행렬이 점차 희소(sparse)해진다. Structured Pruning과 달리 sparse computation에 최적화된 소프트웨어 또는 하드웨어에 적합한 기법. Frankle et al. “WHAT IS THE STATE OF NEURAL NETWORK PRUNING?” ArXiv 2020
  • 34. Unstructured Pruning The Lottery Ticket Hypothesis (LTH) Frankle et al. “The Lottery Ticket Hypothesis: Finding Sparse, Trainable Neural Networks” ICLR 2019 • 네트워크의 초기 파라미터 값을 매 pruning iteration 마다 파라미터 초기화에 사용 1. 네트워크를 임의로 초기화 (where ) 2. 네트워크를 j번 학습하여 파라미터 를 도출 3. 파라미터 를 p% 만큼 pruning하여 마스크 을 생성 4. 파라미터를 로 초기화하고 이를 당첨된 복권(winning ticket)이라 지칭 5. 2~4를 반복 f(x; θ0) θ0 ∼ Dθ θj θj m θ0 f(x; m ⊙ θ0)
  • 35. Unstructured Pruning The Lottery Ticket Hypothesis (LTH) Frankle et al. “The Lottery Ticket Hypothesis: Finding Sparse, Trainable Neural Networks” ArXiv 2018 •간단한 아이디어이지만 매우 좋은 성능을 보임 (3.6%의 가중치만 사용하면서도 성능을 유지) •고착화 되어 있던 Pruning -> Fine-Tuning 방식의 틀을 깨고 새로운 패러다임을 제시
  • 36. Unstructured Pruning Stabilizing the Lottery Ticket Hypothesis (Weight Rewinding) • LTH는 데이터셋 또는 네트워크의 크기가 커졌을 때 불안정한 모습을 보임 • k번째 학습한 파라미터로 네트워크를 초기화하면 학습이 안정화 됨을 보임 (Weight Rewinding) • 논문에서는 총 iteration의 0.1% ~ 7% 정도의 지점을 rewinding point로 언급 Frankle et al. “Stabilizing the Lottery Ticket Hypothesis∗” ArXiv 2019
  • 37. Unstructured Pruning COMPARING REWINDING AND FINE-TUNING IN NEURAL NETWORK PRUNING (Learning Rate Rewinding) • Fine-tuning처럼 학습한 파라미터 값을 그대로 상속받되, Learning Rate Schedule을 특정 시점 (k)으로 rewinding하는 전략을 제안하고 이를 Learning Rate Rewinding이라 명명 • 저자들은 k=0일때 대체로 좋은 성능을 보이므로 k=0으로 두고 따로 튜닝하지 않는 것을 제안 Renda et al. “COMPARING REWINDING AND FINE-TUNING IN NEURAL NETWORK PRUNING” ArXiv 2020
  • 38. Unstructured Pruning Example Configuration: LTH https://github.com/j-marple-dev/model_compression config = { "EPOCHS": 300, "N_PRUNING_ITER": 10, "PRUNE_METHOD": "LotteryTicketHypothesis", "PRUNE_PARAMS": dict( PRUNE_AMOUNT=0.2, STORE_PARAM_BEFORE=0, TRAIN_START_FROM=0 ), }
  • 39. Unstructured Pruning Example Configuration: Weight Rewinding https://github.com/j-marple-dev/model_compression config = { "EPOCHS": 300, "N_PRUNING_ITER": 10, "PRUNE_METHOD": "WeightRewinding", "PRUNE_PARAMS": dict( PRUNE_AMOUNT=0.2, STORE_PARAM_BEFORE=15, TRAIN_START_FROM=15 ), } Rewinding Point
  • 40. Unstructured Pruning Example Configuration: Learning Rate Rewinding https://github.com/j-marple-dev/model_compression config = { "EPOCHS": 300, "N_PRUNING_ITER": 10, "PRUNE_METHOD": "LearningRateRewinding", "PRUNE_PARAMS": dict( PRUNE_AMOUNT=0.2, STORE_PARAM_BEFORE=300, TRAIN_START_FROM=0 ), } K = 0
  • 41. Structured Pruning Channel-Wise Magnitude Based Pruning • 네트워크를 학습한 뒤, Convolution Layer 각 filter의 크기(magnitude)를 구하여 그 크기가 작은 p%의 채널을 pruning하는 방법 1. 모든 convolution filter의 각 가중치에 L1-norm을 취한 것을 합 2. 1에서 구한 값을 기준으로 filter들을 정렬 3. 정렬된 filter 중 값이 작은 p%를 제거 4. 3으로 인해 제거되는 feature map을 염두하여 다음 layer의 filter 차원을 축소 Li et al. “Pruning Filters for Efficient ConvNets” ArXiv 2016
  • 42. Structured Pruning Learning Efficient Convolutional Networks through Network Slimming • 각 convolution layer batchnorm의 scaling parameter 에 L1-norm을 regularizer로 사용 • L1-regularizer의 효과로 가 0에 가까워지는 채널은 점차 비활성화 • 의 값을 기준으로 정렬하여 이 중 작은 p%의 채널을 pruning γ γ γ Liu et al. “Learning Efficient Convolutional Networks through Network Slimming” ArXiv 2017
  • 43. Network Pruning 더 볼만한 논문들 • Yang et al. “NetAdapt: Platform-Aware Neural Network Adaptation for Mobile Applications” ArXiv 2018 • Liu et al. “RETHINKING THE VALUE OF NETWORK PRUNING” ArXiv 2018 • Morcos et al. “One ticket to win them all: generalizing lottery ticket initializations across datasets and optimizers” ArXiv 2019 • Frankle et al. “Linear Mode Connectivity and the Lottery Ticket Hypothesis” ArXiv 2019 • Frankle et al. “WHAT IS THE STATE OF NEURAL NETWORK PRUNING?” ArXiv 2020
  • 45. Network Quantization 파라미터의 값을 좀 더 작은 크기의 타입으로 표현하는 것
  • 46. Quantizer Design Uniform Affine Quantizer • Uniform Affine Quantizer를 이용하여 ( , )의 값의 범위를 가진 floating point 변수를 (0, − 1)의 범위를 가진 integer 변수로 quantization하면 다음과 같다. xmin xmax Nlevels Krishnamoorthi et al. “Quantizing deep convolutional networks for efficient inference: A whitepaper” ArXiv 2018 : Scale : zero point Δ z
  • 47. Quantizer Design Uniform Symmetric Quantizer •Zero-point가 0이며, floating point 변수를 signed integer로 매핑한다. Krishnamoorthi et al. “Quantizing deep convolutional networks for efficient inference: A whitepaper” ArXiv 2018 : ScaleΔ
  • 48. Network Quantization 소분류 • Post Training Quantization: 별도의 학습 없이 weight 또는 weight와 activation을 quantization하는 방법. 데이터의 사용이 제한적인 경우에 사용이 용이하며 또한 절차가 간 단한 편. 아래 표는 32-bit floating point 변수를 8-bit로 quantization 했을 때의 성능손실 을 보여준다. Krishnamoorthi et al. “Quantizing deep convolutional networks for efficient inference: A whitepaper” ArXiv 2018
  • 49. Network Quantization 소분류 • Quantization Aware Training (QAT): Weight 또는 activation이 floating 타입이지만 이 보다 더 작은 타입을 모방하도록(fake-quantized) 더 작은 범위로 값을 사상(mapping)한다. 이때의 weight 또는 activation은 floating type이기 때문에 학습이 가능하다. 아래 표를 통해 Post Training Quantization 보다 QAT가 좀 더 높은 성능을 보임을 확인할 수 있다. Krishnamoorthi et al. “Quantizing deep convolutional networks for efficient inference: A whitepaper” ArXiv 2018
  • 50. Network Pruning 더 볼만한 자료들 • Neural Network Distiller, https://nervanasystems.github.io/distiller/index.html • Microsoft’s NNI, https://nni.readthedocs.io/en/latest/ • Qualcomm’s AIMET, https://github.com/quic/aimet • PyTorch Docs, https://pytorch.org/docs/stable/quantization.html • PyTorch Tutorial, https://pytorch.org/tutorials/advanced/static_quantization_tutorial.html • PyTorch Quantization Example: https://github.com/pytorch/vision/blob/master/torchvision/ models/quantization/mobilenet.py
  • 52. Knowledge Distillation 학습된 큰 네트워크(Teacher)를 작은 네트워크(Student)의 학습 보조로 사용하는 방법
  • 53. Knowledge Distillation Distilling the Knowledge in a Neural Network (a.k.a. Hinton Loss) • Student network와 ground truth label의 cross-entropy + teacher network와 student network의 inference 결과에 대한 KLD loss로 정의 • 는 large teacher network의 출력을 smoothing(flat) 하는 역할을 한다.(Soft Target) • 는 두 loss의 균형을 조절하는 파라미터다. T α Hinton et al. “Distilling the Knowledge in a Neural Network” ArXiv 2015
  • 54. Knowledge Distillation Feature Distillation Methods • Teacher network와 student network의 출력을 이용하는 것과 달리 feature distillation은 네트워크 feature 정보를 이용하여 distillation loss를 정의. • Ruffy et al. (2019), Tian et al. (2020)은 SOTA임을 주장하는 많은 논문들의 실제 재현성 능이 HintonLoss 를 크게 상회하지 못하였고, 특히 feature distillation methods들은 성능 재 현이 매우 어렵다고 밝혔다. Tian et al. “Contrastive Representation Distillation” ICLR 2020 https://github.com/HobbitLong/RepDistiller Ruffy et al. “The State Of Knowledge Distillation For Classification Tasks” ArXiv 2019 https://github.com/karanchahal/distiller HintonLoss
  • 58. 대회 참가에 사용한 코드 저장소를 공개합니다!
  • 60. 알찬 내용이 가득 • Architecture: MixNet / Fast DenseNet • Augmentation: AutoAugment / RandAugment / CutMix / CutOut • Loss: Cross Entropy Loss + Label Smoothing / Hinton Loss • LR Scheduler: Cosine Annealing + Initial Warmup • Unstructured Pruning: LTH / Weight Rewinding / LR Rewinding • Structured Pruning: Magnitude Pruning / Network Slimming / Mag + Slimming • Channel-Wise Pruned Model Shrinker (Experimental) • Quantization: Post Training Quantization / Quantization Aware Training
  • 61. 궁금하신 점은 저장소의 issue에 남겨주세요!