Review: AutoAugment and RandAugment

Guan
工人智慧
Published in
17 min readJan 15, 2020

--

Introduction

Neural Architecture Search 和人類設計網路架構的戰爭,以 2017 年的 NASNet 為濫觴,最近有卡就是任性的 Google 也拿出了新一代的搜尋架構 EfficientNet 。

但從 2012 年的 Alexnet 首先嶄露頭角以來,七年來我們有了許多更強大的模型,對於 Model Topology 有更好的掌握,在 Data Augmentation 的領域卻仍在經常使用同樣也是 2012 年在 ImageNet 上的設置,這就是此二篇的動機:搜尋一套更新更好的 Data Augmentation Strategy。

AutoAugment Introduction

AutoAugment 是在各種資料集上搜尋出能夠最佳化 Validation Set 準確率的Data Augmentation 的演算法,本篇在以下資料集上做過搜尋:

Datasets Being Searched

AutoAugment 只有在 CIFAR-10 、SVHN 和 ImageNet 上搜尋出來,CIFAR-100 使用的是 CIFAR-10 的 AutoAugment,Stanford Cars 使用的是 ImageNet 的 AutoAugment。

實際上看來效果並沒有很大,但事實上比較基準有些不同,譬如是否有 Fine-tuned 或是使用的模型、使用的 Data Augmentation 是什麼。另外也能夠看出對於 Custom Dataset 是不能讓你這樣搞的,一張 P100 動輒要搜尋上千小時,誰受得了,故後面也會提到這搜尋結果的 Transferability ,也就是在某個資料集搜尋的結果,遷移到另一個資料集的效果。

AutoAugment: Searching for best Augmentation policies Directly on the Dataset of Interest

搜尋的作法是這樣的:
我們有一個 RNN controller ,他能在我們設定的搜尋空間中輸出一套 Data Augment Policy ,以固定的訓練設置訓練一個固定架構,得出這個訓練結果的 Validation Accuracy ,再將其回饋給 RNN controller,更新 Policy 並進行下一次訓練。

搜尋空間是這樣的:
一套 Augment Policy 有五個 Sub-Policies ,每一個 Sub-Policies 帶有兩種 Augment 、一個在每個 mini-batch 被使用的 Possibility 以及強度 Magnitudes。

也就是說,每一次模型訓練的開始,RNN 會輸出一套 Policy,帶有五個 Sub-Policies 共 10 種 Operations (Data Augment)。在模型的每個 training step ,會 randomly at uniform 選出一種 Sub-Policy ,其中的兩個 Operation 各有一個機率值決定是否要被應用在該 mini-batch 上,如果是,就會使用當初選好的 Magnitudes 。所以即便同一套 Sub-Policy 被選中,因為其中 Operations 帶有的 Possibility ,表現出的 mini-batch 也不會相同。

在這個模型被訓練完後,算出 Validation Accuracy ,作為該次 Policy 的評分,之後 RNN 在輸出一套 Policy ,重新開始訓練一個模型。

這邊就不細講這個 RNN controller 的 Proximal Policy Optimization 了,就是一種能透過量化 rewards 的 Reinforcement Learning ,這邊的 Rewards 就是 Validation Accuracy ,最終結果是這個 RNN 能夠產生一套提高 Validation Accuracy 最多的 Data Augmentation Policy。

AutoAugment Experiments and Results

左側是訓練集,搜尋 AutoAugment 時是使用 Validation Set,這邊是 Test Set 。Baseline 是基本常見的 Data Augmentation,包含 Flipping 、Crop and Zero Padding 和標準化,Cutout 則是在 Baseline 外再加上了一個 16 x 16 的 Cutout。

值得提到的是 AutoAugment 在 ImageNet 和 CIFAR10 上都是僅使用了部份資料,作者認為若是使用更多的資料,能夠再提升最終的 Validation Accuracy。

The Transferability of Learned Augmentation policies to Other Datasets

AutoAugment 是跟著資料集跑的,但實際的應用情景顯然不太實際,資料集常常會更新,也有各式各樣的資料集,總不能每次都搜尋一次吧。

所以 Transferability 就十分重要,此外,AutoAugment 是否會 overfitting 也是關注的重點:

Also if such transfer happens naturally, we also have clear evidence that AutoAugment does not “overfit” to the dataset of interest and that AutoAugment indeed finds generic transformations that can be applied to all kinds of problems.

總之,就是 AutoAugment 的范用性。

ImageNet AutoAugment Results on Other Dataset

上圖的能看到很大的提升,但顯然有幾點值得質疑:

  1. ImageNet 上能夠轉移到其他小資料集,那如果我使用的是和 ImageNet 情景不同、量級不同,還有多少效果?不同的模型呢?(儘管論文在下一小結宣稱它已經在足夠多的資料集和模型上驗證這件事情,需要更多實驗)
  2. 實驗顯然少了控制組,誰知道究竟是 Transferability 很好,還是只是因為 Data Augmentation 本身就能夠被輕易的 Transfered?應該要在 target dataset 上搜尋一次,再應用 ImageNet AutoAugment,兩相比較才對。

AutoAugment Ablation experiments

這是這篇論文最慘忍的一節了。

  1. Randomizing the probabilities and magnitudes in the augmentation policy

We train a Wide-ResNet-28–10, using the same training procedure as before, for 20 different instances of the randomized probabilities and magnitudes. We find the average error to be 3.0% (with a standard deviation of 0.1%), which is 0.4% worse than the result achieved with the original AutoAugment policy.

不是使用搜尋來的 magnitude 和 possibility ,只差 0.4 % ,你是在逗我吧大哥。果然下一篇 RandAugment 就捨棄了 learned magnitude 和 learned possibility 了。

2. Performance of random policies

The ablation experiments indicate that even data augmentation policies that are randomly sampled from our search space can lead to improvements on CIFAR-10 over the baseline augmentation policy. However, the improvements exhibited by random policies are less than those shown by the AutoAugment policy (2.6% ± 0.1% vs. 3.0% ± 0.1% error rate).

呵呵,一樣,在隨機挑轉 policies 的狀況下,僅減少 0.4 %,所以下一篇 RandAugment 也捨棄了 learned policies。

RandAugment Introduction

AutoAugment 暴力有效,直接在資料集上搜尋最佳策略,但計算量十分巨大的缺點也很明顯,而且我們能夠觀察到在越大的模型、越大的資料集上,提升的幅度越小。

另外,雖然 AutoAugment 似乎有展現在不同資料集上 Transfer 的能力,但論文主要展現的是 ImageNet 找出的結果,使用在小資料集上,除了迴避了 「在小資料集(小模型)上的 AutoAugment 是否也能夠在大資料集(大模型)上有效果」的這個問題外,我們也很難知道究竟是 AutoAugment 發揮作用,還是單純只是引入比 Baseline 更豐富的 Data Augmentation Policy ,使 Validation Accuracy 更好?

而且最重要的一點,在 Ablation Study 中臉被打的啪啪響,不如 Random。

所以,RandAugment 這篇主要針對 AutoAugment 提出了幾點質疑和改進:

  1. 透過小資料集作為跳板資料集 ( proxy task ) 找到的 Data Augmentation Policy 只是次佳解,並不足以應用到不同大小,甚至不同環境的資料上。
  2. RandAugment 使用了非常簡單的方式搜尋、控制 Data Augmentation,只需要簡單的 Grid Search 就足夠搜尋,也只需要兩個參數就能夠足夠控制所有 Data Augmentation Policy。
  3. 能夠在 CIFAR 和 ImageNet 上達到和 AutoAugmentation 幾乎相同的效果。

RandAugment Method

不同於 AutoAugment 在 leaned policies 上使用 learned possibility ,RangAugment 則是使用 uniform possibility ,每一種 Augmentation 都有可能,而且被選到的機率是相等的,如此我們便不需要在這兩者上花費能力搜尋,作者某種程度是相信這兩者並不會大幅影響訓練的成果的,在文章最後也會提出 ablation study,看看實際上會影響多少。

此外,作者也不使用 learned magnitude ,因為在 Population based augmentation: Efficient learning of augmentation policy schedules 觀察到了大多在 AutoAugment 的 learned magnitude 都呈現某種趨勢(像是呈現比例性的變化),所以作者僅使用單一一個值 distortion magnitude M增減所有 Augmentation 的強度,主要也是為了節省搜尋的運算。

好的,去除了 learned possibility 和 learned magnitude 之外,RandAugment 使用另一個參數 N ,代表每一張圖每次會使用的 Augmentation:

如此我們可以很簡單地將所有可能的 NM 列出後,計算出所有組合中對於 Validation Accuracy 最有幫助的,不需要任何大計算量、複雜的演算法。

Test Acc. of CIFAR and SVHN
Test Acc. of ImageNet

上兩張圖能夠看出 RandAugment 也能夠達到與 AutoAugment 一樣,在大資料或大模型上甚至能有更好的效果。我們將模型大小及資料大小與 distortion magnitude M 作比較:

Model Size and Train Set vs Distortion Magnitude

我認為 (a) 和 (c) 的重點在, optimal distortion magnitude 並不會相差太多, 如果最佳值是 15 , 13–17 之間的值就能夠達到相當好的效果,我們不需要 Grid Search 找出最佳值,只需要近似值就好。

另外, (b) 和 (d) 提示我們,在選擇 distortion magnitude 時,越大的模型、越大的資料集需要選擇越大的值。這兩個建議足夠讓我們在 custom dataset 選擇到一個好的 distortion magnitude ,減少在搜尋最佳解的成本。

值得提到的一點是,小資料集上需要更保守的 Data Augmentation Policy 是違反直覺的(一般期望能透過 Data Augmentation 增加資料集所擁有的資訊),文中指出,

Figure 3d demonstrates that the optimal distortion magnitude increases monotonically with training set size. One hypothesis for this counter-intuitive behavior is that aggressive data augmentation leads to a low signal-to-noise ratio in small datasets.

簡而言之,Data Augmentation 能夠增加小資料集的 Variants ,但不能過頭,若使噪聲會遠多於資訊,反而對訓練來說是傷害。

Investigating the dependence on the included transformations

Comparison of retate, translate-x and posterize
Ablation for Different Transformations

RandAugment achieves state-of-the-art results across different tasks and datasets using the same list of transformations. This result suggests that RandAugment is largely insensitive to the selection of transformations for different datasets.

上圖是使用了全部的 14 種 Data Augmentation ,並刪除了該 target augmentation 得到的結果,下圖則是在一個隨機抽樣出來的 subset ,和加入或不加入 target augmentation 做比較。

文中並沒有提到如何對 subset 做抽樣、抽樣幾次等等,比較理想的結果應該會是各有貢獻(14 項中竟然有 6 項是零貢獻甚至是負值),集中在 rotate 和 posterize 有些奇怪,我猜測這些 Augmentation 應該存在某一種 dependency ,某一些會相加,某一些會相牴觸,對這個結果我抱持懷疑。

Learning the probabilities for selecting image transformations

Is Learned Possibility Better?

前頭提到 RandAugmentation 的特色之一就是不做搜尋,不搜尋 magnitude 不搜尋 possibility ,那如果有了呢?

因為使用的 Augmentation 大多都可微分,我們可以將其使用 Backpropagation 更新每一個 Differentiable Augmentation 的機率值,稱之為1st-order density。結論是有效,但還是昂貴的。

Conclusion

前兩篇揭露了,模型的 Generalization 和 Robustness 很有可能是一種 Trade-off ,這也並非首次被提出,譬如
Batch Normalization is a Cause of Adversarial Vulnerability
How Dose Batch Normalization Help Optimization
兩篇的結論恰好互補,闡述了 Batch Normalization 強化了 Generalization 的同時,也必然降低 Robustness 。

這剛好也是一個相當好的切入點,如果能夠理解 Batch Normalization 在訓練過程中扮演的角色,我們就能夠進一步了解到 Generalization 和 Robustness 的本質,但這不是今天的主題,留後再提。

在前一篇 Fourier Hypothesis 中,暗示了 AutoAugument 能夠在某種程度對抗 Adversarial Attack,而 Adversarial Examples Improve Image Recognition 不但提到作為 Data Augmentation 加入的 Adversarial Noise 較小,訓練在 Capacity 較大的模型上,能夠提昇對抗 Adversarial Attack 的能力,而且 Generalization 也能不受影響,再再顯示了 Data Augmentation 的巨大潛力,是進一步強化 Computer Vision Model 的重要工具之一。

這兩篇的操作十分簡單,現也已經 open-source ,重點都還是放在讓資料擁有更多 Variants ,配合模型擁有的適當的 Model Capacity ,使得模型能夠更加 Generalized 且 Robust ,接下來的研究還十分有潛力,值得期待。

--

--