-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a few issues in EfficientNet introduced by API change and rephras…
…e documentation (#1926) * refine efficientnet * pai -> openpai * fix interval * update batch size * move readme to trial examples * update to docs
- Loading branch information
Yuge Zhang
committed
Jan 17, 2020
1 parent
c66438b
commit c6d9f8f
Showing
9 changed files
with
47 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# EfficientNet | ||
|
||
[EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks](https://arxiv.org/abs/1905.11946) | ||
|
||
Use Grid search to find the best combination of alpha, beta and gamma for EfficientNet-B1, as discussed in Section 3.3 in paper. Search space, tuner, configuration examples are provided here. | ||
|
||
## Instructions | ||
|
||
[Example code](https://github.com/microsoft/nni/tree/master/examples/trials/efficientnet) | ||
|
||
1. Set your working directory here in the example code directory. | ||
2. Run `git clone https://github.com/ultmaster/EfficientNet-PyTorch` to clone this modified version of [EfficientNet-PyTorch](https://github.com/lukemelas/EfficientNet-PyTorch). The modifications were done to adhere to the original [Tensorflow version](https://github.com/tensorflow/tpu/tree/master/models/official/efficientnet) as close as possible (including EMA, label smoothing and etc.); also added are the part which gets parameters from tuner and reports intermediate/final results. Clone it into `EfficientNet-PyTorch`; the files like `main.py`, `train_imagenet.sh` will appear inside, as specified in the configuration files. | ||
3. Run `nnictl create --config config_local.yml` (use `config_pai.yml` for OpenPAI) to find the best EfficientNet-B1. Adjust the training service (PAI/local/remote), batch size in the config files according to the environment. | ||
|
||
For training on ImageNet, read `EfficientNet-PyTorch/train_imagenet.sh`. Download ImageNet beforehand and extract it adhering to [PyTorch format](https://pytorch.org/docs/stable/torchvision/datasets.html#imagenet) and then replace `/mnt/data/imagenet` in with the location of the ImageNet storage. This file should also be a good example to follow for mounting ImageNet into the container on OpenPAI. | ||
|
||
## Results | ||
|
||
The follow image is a screenshot, demonstrating the relationship between acc@1 and alpha, beta, gamma. | ||
|
||
![](../../img/efficientnet_search_result.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1 @@ | ||
# EfficientNet | ||
|
||
[EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks](https://arxiv.org/abs/1905.11946) | ||
|
||
Provided here are: Search space and tuners for finding the best tuple (alpha, beta, gamma) for EfficientNet-B1 with grid search, as discussed in Section 3.3 in [paper](https://arxiv.org/abs/1905.11946). | ||
|
||
## Instructions | ||
|
||
1. Set your working directory here in this directory. | ||
2. Run `git clone https://github.com/ultmaster/EfficientNet-PyTorch` to clone this modified version of [EfficientNet-PyTorch](https://github.com/lukemelas/EfficientNet-PyTorch). The modifications were done to adhere to the original [Tensorflow version](https://github.com/tensorflow/tpu/tree/master/models/official/efficientnet) as close as possible (including EMA, label smoothing and etc.); also added are the part which gets parameters from tuner and reports intermediate/final results. Clone it into `EfficientNet-PyTorch`; the files like `main.py`, `train_imagenet.sh` will appear inside, as specified in the configuration files. | ||
3. Run `nnictl create --config config_net.yml` to find the best EfficientNet-B1. Adjust the training service (PAI/local/remote), batch size in the config files according to the environment. | ||
|
||
For training on ImageNet, read `EfficientNet-PyTorch/train_imagenet.sh`. Download ImageNet beforehand and extract it adhering to [PyTorch format](https://pytorch.org/docs/stable/torchvision/datasets.html#imagenet) and then replace `/mnt/data/imagenet` in with the location of the ImageNet storage. This file should also be a good example to follow for mounting ImageNet into the container on OpenPAI. | ||
|
||
## Results | ||
|
||
The follow image is a screenshot, demonstrating the relationship between acc@1 and alpha, beta, gamma. | ||
|
||
![](assets/search_result.png) | ||
[Documentation](https://nni.readthedocs.io/en/latest/TrialExample/EfficientNet.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
authorName: unknown | ||
experimentName: example_efficient_net | ||
trialConcurrency: 4 | ||
maxExecDuration: 99999d | ||
maxTrialNum: 100 | ||
trainingServicePlatform: local | ||
searchSpacePath: search_net.json | ||
useAnnotation: false | ||
tuner: | ||
codeDir: . | ||
classFileName: tuner.py | ||
className: FixedProductTuner | ||
classArgs: | ||
product: 2 | ||
trial: | ||
codeDir: EfficientNet-PyTorch | ||
command: python main.py /data/imagenet -j 12 -a efficientnet --batch-size 48 --lr 0.048 --wd 1e-5 --epochs 5 --request-from-nni | ||
gpuNum: 1 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
{ | ||
"alpha": { | ||
"_type": "quniform", | ||
"_value": [1.0, 2.0, 0.1] | ||
"_value": [1.0, 2.0, 0.05] | ||
}, | ||
"beta": { | ||
"_type": "quniform", | ||
"_value": [1.0, 1.5, 0.1] | ||
"_value": [1.0, 1.5, 0.05] | ||
}, | ||
"gamma": { | ||
"_type": "quniform", | ||
"_value": [1.0, 1.5, 0.1] | ||
"_value": [1.0, 1.5, 0.05] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters