[2020 ICLR] AutoSlim: Towards One-Shot Architecture Search for Channel Numbers

Hyungseop Lee·2024년 10월 29일
0
post-thumbnail

Paper Info.


Abstract

  • 우리는 제약된 자원(e.g., FLOPs, latency, memory footprint, model size) 하에서 더 나은 정확도를 달성하기 위해 neural network의 channel 수를 설정하는 방법을 연구했다.
    이를 위해 simple and one-shot approach인 AutoSlim을 제안한다.

  • 여러 network sample을 training하고 reinforcement learning으로 검색하는 대신, 하나의 slimmable network를 train하여 다양한 channel configurations에 따른 network accuracy를 근사하도록 한다.
    그런 다음, trained된 slimmable model을 반복적으로 평가하고, minimal accuracy drop을 보이는 layer를 greedily slim화했다.
    이 single pass에 의해, 우리는 optimized channel configurations을 얻을 수 있었다.


1. Introduction

  • 이 연구에서 우리는 constrained resources 내에서 better accuracy를 달성하기 위해 channel numbers in a neural network를 설정하는 방법을 연구한다.
    처음 떠오르는 the most brute-force approach는 exhaustive search : 모든 가능한 channel configurations을 전부 훈련해보는 방법이다.
    그러나 이 approach는 cost가 너무 높아 실용적이지 않다.
    (예를 들어, 8개의 layer를 가진 CNN에서 각 layer의 channel 수 후보를 10개로 제한했을 때, 총 10810^8개의 candidate network archietectures가 생성된다)

  • 이 문제를 해결하기 위해, 우리는 AutoSlim이라는 간단하고 one-shot solution을 제안한다.
    우리의 주요 아이디어는 slimmable network를 훈련하여 다양한 channel configurations에 따른 network accuracy를 근사하는 것이다.
    Yu et al.(Yu et al., 2018; Yu & Huang, 2019)은 동일한 architecture를 개별적으로 training하는 것보다 뛰어난 성능을 보이며 임의의 width에서 실행할 수 있는 slimmable networks를 소개했다.
    원래의 목적은 adaptive accuracy-efficiency trade-offs를 제공하는 것이지만, slimmable network는 여러 이유로 benchmark 성능 평가에 특히 적합하다는 것을 발견했다.

    1. slimmable models을 training하는 것은 brute-force approach에 비해 훨씬 빠르다.
    2. trained된 slimmmable model은 임의의 width에서 실행될 수 있어, 다양한 channel configurations 간의 상대적인 성능을 근사할 수 있다.
    3. 동일한 trained slimmable model을 사용하여 다른 resource constraints에 따른 optimal channels을 탐색할 수 있다.
  • AutoSlim에서는 먼저 몇 epoch 동안(e.g., 10% or 20% of full training epochs) slimmable model을 훈련하여 빠르게 benchmark performance estimator를 얻는다.
    그런 다음 trained slimmable model을 반복적으로 평가하고, validation set에서 accuracy drop이 최소화되는 layer를 greedily slim화한다.
    이러한 최적화된 architecture를 개별적으로 또는 a single slimmable network로서 전체 epoch 동안 train
    한다.

  • AutoSlim은 세 가지 기준과 비교하여 더 나은 결과를 달성했다:
    1. the default channel configuration
    2. channel pruning methods on same network architectures (Luo et al., 2017; He et al., 2017; Yang et al., 2018)
    3. reinforcement learning based architecture search methods (He et al., 2018; Tan et al., 2018).

2. Related Work

2.1. Arhictecture Search for Channel Numbers

Neural Architecture Search(NAS)

  • 최근 neural network design을 자동화하려는 관심이 높아지고 있다.
    이러한 자동화된 serached architectures들은 여러 vision and language task에서 성능을 크게 향상시켰다.
    그러나 대부분의 neural architecture search 방법들은 channel configuration을 search space에 포함하지 않고, 대신 human-designed heuristics을 적용했다.
    최근에는 RL 기반 search algorithm이 channel pruning이나 filter 수 검색에 직접 적용되기도 했다.

  • He et al.은 model compression을 위한 AutoML을 제안하며, RL을 활용하여 model compression policy를 제공했다.
    MNasNet은 mobile device에 적합한 network architecture를 filter 크기까지 포함하여 직접 검색하는 방식을 제안했다.
    이 검색 과정에서 각 sampling된 model은 aggressive learning rate를 사용해 5 epoch 동안 훈련되며, 50k개의 validation set으로 평가된다.
    Tan et al.은 architecture 검색 동안 약 8,000개의 model을 sampling했다.
    ...

2.2. Slimmable Networks

  • Slimmable network는 처음 (Yu et al., 2018)에서 소개되었다.
    일반적인 slimmable training algorithm과 switchable BN이 도입되어, 서로 다른 width에서 실행할 수 있는 a single neural network를 학습하게 되었으며,
    runtime에 instant and adaptive accuracy-efficiency trade-offs를 제공했다.
    그러나 switchable BN의 단점은 width를 predefined된 width sets에서만 선택할 수 있다는 점이다.
    이 단점은 (Yu & Huang, 2019)에서 해결되었으며, 저자들은 slimmable network를 임의의 width에서 실행할 수 있도록 확장하여, BN layer가 있는 network와 없는 network 모두에 일반화할 수 있도록 했다.
    또한, sandwich rule과 inplace distillation이라는 두 가지 개선된 training techniques이 제안되어, 학습 과정을 향상시키고 test accuracy를 높혔다.
    더불어, 제안된 방법을 통해 각 layer가 inference 중 독립적으로 channel 수를 조정할 수 있는 nonuniform universally slimmable network를 학습할 수 있게 되었다.
    즉, nonuniform universally slimmable network의 각 layer는 inference 중에 channel 수를 독립적으로 조정할 수 있다.
    본 연구에서는 특별히 언급하지 않는 한, nonuniform universally slimmable networks를 단순히 slimmable network라고 지칭한다.
    slimmable network의 원래 목표는 다양한 device에서 runtime 시 instant and adaptive accuracy-efficiency trade-offs를 제공하는 것이었으나,
    우리는 slimmable network를 사용해 neural networks의 channel configurations을 검색하는 방법을 제안
    한다.

3. AutoSlim : Network Slimming by Slimmable Networks

3.1. Overview

  • channel configuration serach의 목표는 각 layer의 channel 수를 최적화하여, 제한된 자원(e.g. FLOPs, latency, memory footprint, model size) 내에서 더 높은 accuracy를 달성할 수 있는 network architecture를 만드는 것이다.
    이 접근 방식은 개념적으로 간단하며 두 가지 주요 step으로 이루어진다.
    1. 주어진 network architecture에 대해 a few epochs(e.g. 10% to 20% of full training epochs) 동안 slimmable model을 학습한다.
      학습 과정에서 다양한 channel configuration을 가진 여러 sub-networks가 sampling되고 학습된다.
      학습이 끝난 후, 학습된 weights와 해당 computational graph를 사용하여 sub-network architecture를 즉시 inference에 사용할 수 있다.
    2. 이후, 학습된 slimmable model을 validation set에서 반복적으로 평가한다.
      각 iteration에서, validation set에서 feed-forward evaluation accuracy를 비교하여 slim할 layer를 결정한다.
      우리는 layer with minimal accuracy drop을 greedily slim하여, efficiency constraints에 도달할 때까지 이 과정을 반복한다.
      이 단계에서는 추가 학습이 필요하지 않다.
  • 이 approach의 flow diagram은 Figure 2에 나와 있으며,
    FLOPs, latency, memory footprint and model size가 channel configuration과 runtime environment에 따라 결정되므로 다양한 자원 제약에 대해 유연하게 적용할 수 있다.
    step 2의 a single pass of greedy slimming을 통해 서로 다른 channel configurations의 tuple(FLOPs, latency, memory footprint, model size, accuracy)을 얻을 수 있다.
    latency와 accuracy는 상대적인 값으로, latency는 HW에 따라 다를 수 있으며, 전체 epoch 동안 학습하면 accuracy가 개선될 수 있다.
    channel 수를 최적화하는 설정에서는 이러한 상대적 값을 성능 estimators로 활용한다.

Discussion

  • 우리는 network channel pruning methods 및 network architecture search methods와 본 접근 방식의 flow diagram을 비교한다.많은 network channel pruning 방법은 Figure 3a와 같이 일반적인 iterative training-pruning-finetuning pipeline을 따른다.
    본 접근 방식과 비교했을 때, 대부분의 network channel pruning methods는 the importance of trained weights에 기반하여
    slim할 channel이 보통 개별 index(e.g., 4th, 7th, 9th channel are left as important channels while all others are pruned)로 구성된다.
    본 접근 방식에서는 slimmable training 후 the importance of channel numbers가 index에 의해 암묵적으로 순위가 매겨지며,
    the importance of channel numbers에 중점을 두고 lower-index channels(예 : 1st to 3rd channels are left while 4th to 10th channels are slimmed in step (2))을 유지한다.
  • Network architecture search methods는 보통 세 가지 주요 구성 요소인 search space, search strategy, and performance estimation strategy로 구성된다.
    전형적인 pipeline은 Figure 3b에 나와 있다.
    먼저 search space가 정의되면, search agent가 network architecture를 sampling한다.
    architecture는 performance estimator로 전달되어 prediction accuracy after training and/or network runtime latency과 같은 rewards를 agent에게 return한다.
    search agent는 repetitive loop를 통해 더 나은 network architecture architectures를 학습한다.
    network architecture search methods의 주요 단점은 높은 computational cost and time cost이다.
    최근에는 differentiable archietecture search methods가 제안되었으나, channel 수를 직접 search하는 데는 적용할 수 없다.
    이들 중 대부분은 여전히 channel 수 설정을 위한 human-designed heuristics을 사용하여, human bias를 도입할 가능성이 있다.

3.2. Training Slimmable Networks

Warmup

  • slimmable networks를 위한 training techniques을 간단히 복습하면서 시작한다.
    slimmable network는 처음에 서로 다른 sub-networks에 개별 BN을 적용하는 switchable BN을 통해 소개되고 학습되었다.
    training 중에는 현재 mini-batch의 mean and variance로 feature를 normalized하므로,
    (Yu & Huang, 2019)에서는 switchable BN을 간단히 수정하여 학습 후 BN 통계를 재조정하는 방법을 도입했다.
    이 간단한 수정으로, 임의의 channel 수로 실행할 수 있는 general slimmable network를 학습할 수 있다.
    또한 sandwich rule과 inplace distillation이라는 두 가지 개선된 training techniques이 학습 과정을 강화하고 test accuracy를 높히기 위해 동비되었다.
    우리는 기본적으로 slimmable model을 학습할 때 이 모든 기법을 사용했다.

Assumption

  • 우리의 approach는 동일한 channel configuration이 주어졌을 때 slimmable model이 개별적으로 학습된 model들의 좋은 accuracy estimator라는 가정에 기반한다.
    보다 구체적으로는, 서로 다른 channel configuration을 가진 network 간의 the relative ranking of accuracy(상대적인 accuracy 순위)에 관심이 있다.
    우리는 slimmable model의 instant inference accuracy를 performance estimator로 사용한다.
    유사한 방법들에서도 assumptions과 approximations이 흔히 존재한다는 점을 주목했다.

The Search Space

  • slimmable model의 실행 가능한 sub-networks들은 주어진 network architecture의 the search space of channel configurations을 구성한다.
    slimmable model을 학습하기 위해, 우리는 간단히 두 개의 width ratio를 channel 수의 상한선과 하한선으로 설정한다.
    예를 들어, 모든 mobile network에 대해, 0.15x에서 1.5x 사이에서 실행 가능한 slimmable model을 학습한다.
    각 training iteration마다, 각 layer의 channel 수를 무작위로 독립적으로 sampling한다.
    residual network에서는 먼저 identity 경로의 channel 수를 sampling한 후, 각 residual block 내부의 channel 수를 무작위로 독립적으로 sampling한다.
    또한, 첫 번째 conv layer과 마지막 fc layer를 포함하여 모든 layer를 slimmable하게 만든다.
    각 layer에서는 channel을 group으로 균등하게 나눠서(e.g. 10개의 groups) search space를 줄인다.
    즉, 학습이나 slimming 과정에서 개별 channel이 아닌 전체 group을 sampling하거나 제거한다.
    channel grouping에도 불구하고, search space는 여전히 크다.
    예를 들어, 10개의 layer와 각 layer에 10개의 channel group이 있는 10-layer network의 경우, 총 candidate channel configurations은 101010^{10}이다.
  • 우리는 PyTorch에서 synchorized stochastic gradient descent를 사용하여 distributed training framework를 구현했다.
    각 process에서 다른 random seed를 설정하여 각 GPU가 각 SGD training step에서 다양한 channel configurations을 sampling하도록 한다.
    (Yu et al., 2018)에서 소개한 모든 다른 기법과 (Goyal et al., 2017)에서 소개한 분산 학습 기법들이 기본적으로 사용다.

3.3. Greedy Slimming

  • slimmable model을 학습한 후, 우리는 이를 validation set에서 평가했다.(training set에서 임의로 50K image를 validation set로 사용).
    이후, accuracy drop이 최소인 layer를 greedily slim했다.
    iterative slimming 과정에서 다양한 resource constraints 하에서 optimized된 channel configurations을 얻게 된다.
    가장 엄격한 constraint(e.g., 50M FLOPs or 30ms CPU latency)에 도달할 때까지 이를 계속 진행했다.

Large Batch Size

  • greedy slimming 중에는 training이 포함되지 않으므로 model을 evaluation mode에 두고(no gradients are required),
    이를 통해 더 큰 batch size를 사용할 수 있다(예를 들어, slimming 중에는 각 GPU 당 mini-batch size를 2048로 설정하여 총 8개의 V100 GPU를 사용).
    large batch size는 두 가지 이점이 있다.
    1. 이전 연구에 따르면, batch size가 2K 이상일 때 BN 통계가 정화핵지므로, greedy slimming 중 BN의 post-statistics를 추가 비용 없이 online으로 계산할 수 있다.
    2. large batch size를 통해 단순히 하나의 feed-forward prediction accuracy를 performance estimator로 사용할 수 있다.
      실제로, 우리는 이 방법이 greedy slimming을 가속화하고 구현을 단순화하며 최종 성능에 영향을 주지 않음을 확인했다.

Training Optimized Networks

  • architecture search methods와 유사하게, 검색 후에는 이러한 최적화된 network architecture를 처음부터 다시 학습한다.
    기본적으로 우리는 약 200M, 300M, 500M FLOPs의 network를 대상으로 검색하고, slimmable model을 학습한다.

요약

이 논문은 slimmable network 연구이기도 하지만, 최적의 width configurations을 검색하는 방법을 제시하기 때문에 중점은 NAS인듯(Network Architecture Search)

profile
Efficient Deep Learning

0개의 댓글