Idea


저자들이 이전에 제시한 AutoAugment는 강화학습을 이용해서 최적의 Augmentation 방법을 탐색했다. 이 방식은 지나치게 큰 계산량을 요구한다는 단점이 있다. 계산량을 조금이라도 줄이기 위해 사용할 모형의 크기와 데이터의 크기를 줄인 “proxy task”를 사용하는데, 이 역시 sub-optimal한 탐색 결과를 준다는 단점이 있다.

RandAugment는 보다 실용적으로 사용할 수 있다. 최적의 조합을 찾기 위한 탐색 공간을 2차원의 매개변수 (N, M) = (적용할 transform의 개수, magnitude of transforms)로 줄여서 계산량이 줄어든다. 뿐만 아니라, 매개변수가 커질수록 regularization을 더 강하게 해주는 효과가 있으므로, 모형의 표현력과 데이터셋의 크기에 따라 직접 조절하기도 쉽다는 장점이 있다.

Code


https://github.com/ildoonet/pytorch-randaugment/blob/master/RandAugment/augmentations.py#L161

class RandAugment:
    def __init__(**self**, n, m):
**self**.n = n
**self**.m = m# [0, 30]
**self**.augment_list = augment_list()

    def __call__(**self**, img):
        ops = random.choices(**self**.augment_list, k=**self**.n)
        for op, minval, maxval in ops:
            val = (**float**(**self**.m) / 30) ***float**(maxval - minval) + minval
            img = op(img, val)

        return img

https://github.com/ildoonet/pytorch-randaugment/blob/master/RandAugment/augmentations.py#L161

def augment_list():*# 16 oeprations and their ranges
	# <https://github.com/google-research/uda/blob/master/image/randaugment/policies.py#L57>
	# l = [
	#     (Identity, 0., 1.0),
	#     (ShearX, 0., 0.3),  # 0
	#     (ShearY, 0., 0.3),  # 1
	#     (TranslateX, 0., 0.33),  # 2
	#     (TranslateY, 0., 0.33),  # 3
	#     (Rotate, 0, 30),  # 4
	#     (AutoContrast, 0, 1),  # 5
	#     (Invert, 0, 1),  # 6
	#     (Equalize, 0, 1),  # 7
	#     (Solarize, 0, 110),  # 8
	#     (Posterize, 4, 8),  # 9
	#     # (Contrast, 0.1, 1.9),  # 10
	#     (Color, 0.1, 1.9),  # 11
	#     (Brightness, 0.1, 1.9),  # 12
	#     (Sharpness, 0.1, 1.9),  # 13
	#     # (Cutout, 0, 0.2),  # 14
	#     # (SamplePairing(imgs), 0, 0.4),  # 15
	# ]

	# <https://github.com/tensorflow/tpu/blob/8462d083dd89489a79e3200bcc8d4063bf362186/models/official/efficientnet/autoaugment.py#L50*5>
    l = [
        (AutoContrast, 0, 1),
        (Equalize, 0, 1),
        (Invert, 0, 1),
        (Rotate, 0, 30),
        (Posterize, 0, 4),
        (Solarize, 0, 256),
        (SolarizeAdd, 0, 110),
        (Color, 0.1, 1.9),
        (Contrast, 0.1, 1.9),
        (Brightness, 0.1, 1.9),
        (Sharpness, 0.1, 1.9),
        (ShearX, 0., 0.3),
        (ShearY, 0., 0.3),
        (CutoutAbs, 0, 40),
        (TranslateXabs, 0., 100),
        (TranslateYabs, 0., 100),
    ]

    return l

Experiments


CIFAR-100에서 Wide-ResNet-28-10을 모형으로 사용한 경우의 Test Accuracy는 81.2% 에서 RandAugment를 적용할 경우에는 83.3% 로 2.1%의 성능향상을 보인다. 저자들이 주장한 성능과 같은 결과(83.3%)를 재현하기 위한 hyperparameter는 다음을 참고한다.

기타 참고