From 42c4dc7fa806155e63d01eb6ea3d9543b83b144d Mon Sep 17 00:00:00 2001 From: Yimin Jiang Date: Wed, 2 Jan 2019 16:44:09 +0800 Subject: [PATCH 1/3] Set ImageNet data augmentation by default https://github.com/apache/incubator-mxnet/blob/a38278ddebfcc9459d64237086cd7977ec20c70e/example/image-classification/train_imagenet.py#L42 When I try to train imagenet with this line commented, the train-accuracy reaches 99% while the validation-accuracy is only less than 50% (single machine, 8 GPUs, global batchsize=2048, Resnet50). Absolutely this is overfitting. Then I uncomment this line and try again with the same experiment settings. This time both train and validation accuracy converge to about 70%. Thus, it seems that this data augmentation is pretty important for ImageNet training. Perhaps it will be better to uncomment this as default, so that future developers won't get confused by the over-fit issue. --- example/image-classification/train_imagenet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/image-classification/train_imagenet.py b/example/image-classification/train_imagenet.py index 0835f5d3ba9b..32bcd848cee8 100644 --- a/example/image-classification/train_imagenet.py +++ b/example/image-classification/train_imagenet.py @@ -39,7 +39,7 @@ def set_imagenet_aug(aug): data.add_data_args(parser) data.add_data_aug_args(parser) # uncomment to set standard augmentations for imagenet training - # set_imagenet_aug(parser) + set_imagenet_aug(parser) parser.set_defaults( # network network = 'resnet', From 52f2945cf1158427969722fb4f829e745fc6d212 Mon Sep 17 00:00:00 2001 From: Yimin Jiang Date: Tue, 19 Mar 2019 10:49:50 +0800 Subject: [PATCH 2/3] Add argument for imagenet data augmentation --- example/image-classification/common/fit.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/example/image-classification/common/fit.py b/example/image-classification/common/fit.py index 5775f30bd885..8e8b0197960a 100755 --- a/example/image-classification/common/fit.py +++ b/example/image-classification/common/fit.py @@ -142,6 +142,8 @@ def add_fit_args(parser): train.add_argument('--profile-server-suffix', type=str, default='', help='profile server actions into a file with name like rank1_ followed by this suffix \ during distributed training') + train.add_argument('--use-imagenet-data-augmentation', type=int, default=0, + help='enable data augmentation of ImageNet data, default disabled') return train @@ -335,4 +337,4 @@ def fit(args, network, data_loader, **kwargs): if args.profile_server_suffix: mx.profiler.set_state(state='run', profile_process='server') if args.profile_worker_suffix: - mx.profiler.set_state(state='run', profile_process='worker') \ No newline at end of file + mx.profiler.set_state(state='run', profile_process='worker') From bd4faf00740b93faa1134b0fd81cf88ca0d577ff Mon Sep 17 00:00:00 2001 From: Yimin Jiang Date: Tue, 19 Mar 2019 10:53:38 +0800 Subject: [PATCH 3/3] Enable data-aug with argument --- example/image-classification/train_imagenet.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/image-classification/train_imagenet.py b/example/image-classification/train_imagenet.py index 32bcd848cee8..421c15db73ad 100644 --- a/example/image-classification/train_imagenet.py +++ b/example/image-classification/train_imagenet.py @@ -38,8 +38,6 @@ def set_imagenet_aug(aug): fit.add_fit_args(parser) data.add_data_args(parser) data.add_data_aug_args(parser) - # uncomment to set standard augmentations for imagenet training - set_imagenet_aug(parser) parser.set_defaults( # network network = 'resnet', @@ -56,6 +54,8 @@ def set_imagenet_aug(aug): dtype = 'float32' ) args = parser.parse_args() + if args.use_imagenet_data_augmentation: + set_imagenet_aug(parser) # load network from importlib import import_module