|
|
@ -8,11 +8,9 @@
|
|
|
|
- [Script and Sample Code](#script-and-sample-code)
|
|
|
|
- [Script and Sample Code](#script-and-sample-code)
|
|
|
|
- [Training Process](#training-process)
|
|
|
|
- [Training Process](#training-process)
|
|
|
|
- [Evaluation Process](#evaluation-process)
|
|
|
|
- [Evaluation Process](#evaluation-process)
|
|
|
|
- [Evaluation](#evaluation)
|
|
|
|
|
|
|
|
- [Model Description](#model-description)
|
|
|
|
- [Model Description](#model-description)
|
|
|
|
- [Performance](#performance)
|
|
|
|
- [Performance](#performance)
|
|
|
|
- [Training Performance](#evaluation-performance)
|
|
|
|
- [Evaluation Performance](#evaluation-performance)
|
|
|
|
- [Inference Performance](#evaluation-performance)
|
|
|
|
|
|
|
|
- [Description of Random Situation](#description-of-random-situation)
|
|
|
|
- [Description of Random Situation](#description-of-random-situation)
|
|
|
|
- [ModelZoo Homepage](#modelzoo-homepage)
|
|
|
|
- [ModelZoo Homepage](#modelzoo-homepage)
|
|
|
|
|
|
|
|
|
|
|
@ -22,7 +20,6 @@ TinyNets are a series of lightweight models obtained by twisting resolution, dep
|
|
|
|
|
|
|
|
|
|
|
|
[Paper](https://arxiv.org/abs/2010.14819): Kai Han, Yunhe Wang, Qiulin Zhang, Wei Zhang, Chunjing Xu, Tong Zhang. Model Rubik's Cube: Twisting Resolution, Depth and Width for TinyNets. In NeurIPS 2020.
|
|
|
|
[Paper](https://arxiv.org/abs/2010.14819): Kai Han, Yunhe Wang, Qiulin Zhang, Wei Zhang, Chunjing Xu, Tong Zhang. Model Rubik's Cube: Twisting Resolution, Depth and Width for TinyNets. In NeurIPS 2020.
|
|
|
|
|
|
|
|
|
|
|
|
Note: We have only released TinyNet-C for now, and will release other TinyNets soon.
|
|
|
|
|
|
|
|
# [Model architecture](#contents)
|
|
|
|
# [Model architecture](#contents)
|
|
|
|
|
|
|
|
|
|
|
|
The overall network architecture of TinyNet is show below:
|
|
|
|
The overall network architecture of TinyNet is show below:
|
|
|
@ -44,42 +41,45 @@ Dataset used: [ImageNet 2012](http://image-net.org/challenges/LSVRC/2012/)
|
|
|
|
- Hardware (GPU)
|
|
|
|
- Hardware (GPU)
|
|
|
|
- Framework
|
|
|
|
- Framework
|
|
|
|
- [MindSpore](https://www.mindspore.cn/install/en)
|
|
|
|
- [MindSpore](https://www.mindspore.cn/install/en)
|
|
|
|
- For more information, please check the resources below:
|
|
|
|
- For more information, please check the resources below:
|
|
|
|
- [MindSpore Tutorials](https://www.mindspore.cn/tutorial/training/en/master/index.html)
|
|
|
|
- [MindSpore Tutorials](https://www.mindspore.cn/tutorial/training/en/master/index.html)
|
|
|
|
- [MindSpore Python API](https://www.mindspore.cn/doc/api_python/en/master/index.html)
|
|
|
|
- [MindSpore Python API](https://www.mindspore.cn/doc/api_python/en/master/index.html)
|
|
|
|
|
|
|
|
|
|
|
|
# [Script description](#contents)
|
|
|
|
# [Script Description](#contents)
|
|
|
|
|
|
|
|
|
|
|
|
## [Script and sample code](#contents)
|
|
|
|
## [Script and Sample Code](#contents)
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```markdown
|
|
|
|
.tinynet
|
|
|
|
.tinynet
|
|
|
|
├── Readme.md # descriptions about tinynet
|
|
|
|
├── README.md # descriptions about tinynet
|
|
|
|
├── script
|
|
|
|
├── script
|
|
|
|
│ ├── eval.sh # evaluation script
|
|
|
|
│ ├── eval.sh # evaluation script
|
|
|
|
│ ├── train_1p_gpu.sh # training script on single GPU
|
|
|
|
│ ├── train_1p_gpu.sh # training script on single GPU
|
|
|
|
│ └── train_distributed_gpu.sh # distributed training script on multiple GPUs
|
|
|
|
│ └── train_distributed_gpu.sh # distributed training script on multiple GPUs
|
|
|
|
├── src
|
|
|
|
├── src
|
|
|
|
│ ├── callback.py # loss and checkpoint callbacks
|
|
|
|
│ ├── callback.py # loss, ema, and checkpoint callbacks
|
|
|
|
│ ├── dataset.py # data processing
|
|
|
|
│ ├── dataset.py # data preprocessing
|
|
|
|
│ ├── loss.py # label-smoothing cross-entropy loss function
|
|
|
|
│ ├── loss.py # label-smoothing cross-entropy loss function
|
|
|
|
│ ├── tinynet.py # tinynet architecture
|
|
|
|
│ ├── tinynet.py # tinynet architecture
|
|
|
|
│ └── utils.py # utility functions
|
|
|
|
│ └── utils.py # utility functions
|
|
|
|
├── eval.py # evaluation interface
|
|
|
|
├── eval.py # evaluation interface
|
|
|
|
└── train.py # training interface
|
|
|
|
└── train.py # training interface
|
|
|
|
```
|
|
|
|
```
|
|
|
|
## [Training process](#contents)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Launch
|
|
|
|
### [Training process](#contents)
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
#### Launch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
# training on single GPU
|
|
|
|
# training on single GPU
|
|
|
|
sh train_1p_gpu.sh
|
|
|
|
sh train_1p_gpu.sh
|
|
|
|
# training on multiple GPUs, the number after -n indicates how many GPUs will be used for training
|
|
|
|
# training on multiple GPUs, the number after -n indicates how many GPUs will be used for training
|
|
|
|
sh train_distributed_gpu.sh -n 8
|
|
|
|
sh train_distributed_gpu.sh -n 8
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
Inside train.sh, there are hyperparameters that can be adjusted during training, for example:
|
|
|
|
Inside train.sh, there are hyperparameters that can be adjusted during training, for example:
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
--model tinynet_c model to be used for training
|
|
|
|
--model tinynet_c model to be used for training
|
|
|
|
--drop 0.2 dropout rate
|
|
|
|
--drop 0.2 dropout rate
|
|
|
|
--drop-connect 0 drop connect rate
|
|
|
|
--drop-connect 0 drop connect rate
|
|
|
@ -102,22 +102,25 @@ Inside train.sh, there are hyperparameters that can be adjusted during training,
|
|
|
|
--GPU using GPU for training
|
|
|
|
--GPU using GPU for training
|
|
|
|
--dataset_sink using sink mode
|
|
|
|
--dataset_sink using sink mode
|
|
|
|
```
|
|
|
|
```
|
|
|
|
The config above was used to train tinynets on ImageNet (change drop-connect to 0.2 for training tinynet-b)
|
|
|
|
|
|
|
|
|
|
|
|
The config above was used to train tinynets on ImageNet (change drop-connect to 0.1 for training tinynet_b)
|
|
|
|
|
|
|
|
|
|
|
|
> checkpoints will be saved in the ./device_{rank_id} folder (single GPU)
|
|
|
|
> checkpoints will be saved in the ./device_{rank_id} folder (single GPU)
|
|
|
|
or ./device_parallel folder (multiple GPUs)
|
|
|
|
or ./device_parallel folder (multiple GPUs)
|
|
|
|
|
|
|
|
|
|
|
|
## [Eval process](#contents)
|
|
|
|
### [Evaluation Process](#contents)
|
|
|
|
|
|
|
|
|
|
|
|
### Launch
|
|
|
|
#### Launch
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
```bash
|
|
|
|
# infer example
|
|
|
|
# infer example
|
|
|
|
|
|
|
|
|
|
|
|
sh eval.sh
|
|
|
|
sh eval.sh
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
Inside the eval.sh, there are configs that can be adjusted during inference, for example:
|
|
|
|
Inside the eval.sh, there are configs that can be adjusted during inference, for example:
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
--num-classes 1000
|
|
|
|
--num-classes 1000
|
|
|
|
--batch-size 128
|
|
|
|
--batch-size 128
|
|
|
|
--workers 8
|
|
|
|
--workers 8
|
|
|
@ -126,13 +129,14 @@ Inside the eval.sh, there are configs that can be adjusted during inference, for
|
|
|
|
--ckpt /path_to_EMA_checkpoint/
|
|
|
|
--ckpt /path_to_EMA_checkpoint/
|
|
|
|
--dataset_sink > tinynet_c_eval.log 2>&1 &
|
|
|
|
--dataset_sink > tinynet_c_eval.log 2>&1 &
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
> checkpoint can be produced in training process.
|
|
|
|
> checkpoint can be produced in training process.
|
|
|
|
|
|
|
|
|
|
|
|
# [Model Description](#contents)
|
|
|
|
# [Model Description](#contents)
|
|
|
|
|
|
|
|
|
|
|
|
## [Performance](#contents)
|
|
|
|
## [Performance](#contents)
|
|
|
|
|
|
|
|
|
|
|
|
#### Evaluation Performance
|
|
|
|
### Evaluation Performance
|
|
|
|
|
|
|
|
|
|
|
|
| Model | FLOPs | Latency* | ImageNet Top-1 |
|
|
|
|
| Model | FLOPs | Latency* | ImageNet Top-1 |
|
|
|
|
| ------------------- | ----- | -------- | -------------- |
|
|
|
|
| ------------------- | ----- | -------- | -------------- |
|
|
|
|