You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 13 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. # InceptionV4 for Ascend/GPU
  2. - [InceptionV4 Description](#InceptionV4-description)
  3. - [Model Architecture](#model-architecture)
  4. - [Dataset](#dataset)
  5. - [Features](#features)
  6. - [Mixed Precision](#mixed-precision)
  7. - [Environment Requirements](#environment-requirements)
  8. - [Script Description](#script-description)
  9. - [Script and Sample Code](#script-and-sample-code)
  10. - [Training Process](#training-process)
  11. - [Evaluation Process](#evaluation-process)
  12. - [Evaluation](#evaluation)
  13. - [Model Description](#model-description)
  14. - [Performance](#performance)
  15. - [Training Performance](#evaluation-performance)
  16. - [Inference Performance](#evaluation-performance)
  17. - [Description of Random Situation](#description-of-random-situation)
  18. - [ModelZoo Homepage](#modelzoo-homepage)
  19. # [InceptionV4 Description](#contents)
  20. Inception-v4 is a convolutional neural network architecture that builds on previous iterations of the Inception family by simplifying the architecture and using more inception modules than Inception-v3. This idea was proposed in the paper Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning, published in 2016.
  21. [Paper](https://arxiv.org/pdf/1602.07261.pdf) Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, Alex Alemi. Computer Vision and Pattern Recognition[J]. 2016.
  22. # [Model architecture](#contents)
  23. The overall network architecture of InceptionV4 is show below:
  24. [Link](https://arxiv.org/pdf/1602.07261.pdf)
  25. # [Dataset](#contents)
  26. Dataset used can refer to paper.
  27. - Dataset size: 125G, 1250k colorful images in 1000 classes
  28. - Train: 120G, 1200k images
  29. - Test: 5G, 50k images
  30. - Data format: RGB images.
  31. - Note: Data will be processed in src/dataset.py
  32. # [Features](#contents)
  33. ## [Mixed Precision(Ascend)](#contents)
  34. The [mixed precision](https://www.mindspore.cn/tutorial/training/en/master/advanced_use/enable_mixed_precision.html) training method accelerates the deep learning neural network training process by using both the single-precision and half-precision data formats, and maintains the network precision achieved by the single-precision training at the same time. Mixed precision training can accelerate the computation process, reduce memory usage, and enable a larger model or batch size to be trained on specific hardware.
  35. For FP16 operators, if the input data type is FP32, the backend of MindSpore will automatically handle it with reduced precision. Users could check the reduced-precision operators by enabling INFO log and then searching ‘reduce precision’.
  36. # [Environment Requirements](#contents)
  37. - Hardware(Ascend/GPU)
  38. - Prepare hardware environment with Ascend processor.
  39. - or prepare GPU processor.
  40. - Framework
  41. - [MindSpore](https://www.mindspore.cn/install/en)
  42. - For more information, please check the resources below:
  43. - [MindSpore Tutorials](https://www.mindspore.cn/tutorial/training/en/master/index.html)
  44. - [MindSpore Python API](https://www.mindspore.cn/doc/api_python/en/master/index.html)
  45. # [Script description](#contents)
  46. ## [Script and sample code](#contents)
  47. ```shell
  48. .
  49. └─Inception-v4
  50. ├─README.md
  51. ├─scripts
  52. ├─run_distribute_train_gpu.sh # launch distributed training with gpu platform(8p)
  53. ├─run_eval_gpu.sh # launch evaluating with gpu platform
  54. ├─run_standalone_train_ascend.sh # launch standalone training with ascend platform(1p)
  55. ├─run_distribute_train_ascend.sh # launch distributed training with ascend platform(8p)
  56. └─run_eval_ascend.sh # launch evaluating with ascend platform
  57. ├─src
  58. ├─config.py # parameter configuration
  59. ├─dataset.py # data preprocessing
  60. ├─inceptionv4.py # network definition
  61. └─callback.py # eval callback function
  62. ├─eval.py # eval net
  63. ├─export.py # export checkpoint, surpport .onnx, .air, .mindir convert
  64. └─train.py # train net
  65. ```
  66. ## [Script Parameters](#contents)
  67. ```python
  68. Major parameters in train.py and config.py are:
  69. 'is_save_on_master' # save checkpoint only on master device
  70. 'batch_size' # input batchsize
  71. 'epoch_size' # total epoch numbers
  72. 'num_classes' # dataset class numbers
  73. 'work_nums' # number of workers to read data
  74. 'loss_scale' # loss scale
  75. 'smooth_factor' # label smoothing factor
  76. 'weight_decay' # weight decay
  77. 'momentum' # momentum
  78. 'amp_level' # precision training, Supports [O0, O2, O3]
  79. 'decay' # decay used in optimize function
  80. 'epsilon' # epsilon used in iptimize function
  81. 'keep_checkpoint_max' # max numbers to keep checkpoints
  82. 'save_checkpoint_epochs' # save checkpoints per n epoch
  83. 'lr_init' # init leaning rate
  84. 'lr_end' # end of learning rate
  85. 'lr_max' # max bound of learning rate
  86. 'warmup_epochs' # warmup epoch numbers
  87. 'start_epoch' # number of start epoch range[1, epoch_size]
  88. ```
  89. ## [Training process](#contents)
  90. ### Usage
  91. You can start training using python or shell scripts. The usage of shell scripts as follows:
  92. - Ascend:
  93. ```bash
  94. # distribute training example(8p)
  95. sh scripts/run_distribute_train_ascend.sh RANK_TABLE_FILE DATA_PATH DATA_DIR
  96. # standalone training
  97. sh scripts/run_standalone_train_ascend.sh DEVICE_ID DATA_DIR
  98. ```
  99. > Notes:
  100. > RANK_TABLE_FILE can refer to [Link](https://www.mindspore.cn/tutorial/training/en/master/advanced_use/distributed_training_ascend.html) , and the device_ip can be got as [Link](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/utils/hccl_tools). For large models like InceptionV4, it's better to export an external environment variable `export HCCL_CONNECT_TIMEOUT=600` to extend hccl connection checking time from the default 120 seconds to 600 seconds. Otherwise, the connection could be timeout since compiling time increases with the growth of model size.
  101. >
  102. > This is processor cores binding operation regarding the `device_num` and total processor numbers. If you are not expect to do it, remove the operations `taskset` in `scripts/run_distribute_train.sh`
  103. - GPU:
  104. ```bash
  105. # distribute training example(8p)
  106. sh scripts/run_distribute_train_gpu.sh DATA_PATH
  107. ```
  108. ### Launch
  109. ```bash
  110. # training example
  111. shell:
  112. Ascend:
  113. # distribute training example(8p)
  114. sh scripts/run_distribute_train_ascend.sh RANK_TABLE_FILE DATA_PATH DATA_DIR
  115. # standalone training
  116. sh scripts/run_standalone_train_ascend.sh DEVICE_ID DATA_DIR
  117. GPU:
  118. # distribute training example(8p)
  119. sh scripts/run_distribute_train_gpu.sh DATA_PATH
  120. ```
  121. ### Result
  122. Training result will be stored in the example path. Checkpoints will be stored at `ckpt_path` by default, and training log will be redirected to `./log.txt` like following.
  123. - Ascend
  124. ```python
  125. epoch: 1 step: 1251, loss is 5.4833196
  126. Epoch time: 520274.060, per step time: 415.887
  127. epoch: 2 step: 1251, loss is 4.093194
  128. Epoch time: 288520.628, per step time: 230.632
  129. epoch: 3 step: 1251, loss is 3.6242008
  130. Epoch time: 288507.506, per step time: 230.622
  131. ```
  132. - GPU
  133. ```python
  134. epoch: 1 step: 1251, loss is 6.49775
  135. Epoch time: 1487493.604, per step time: 1189.044
  136. epoch: 2 step: 1251, loss is 5.6884665
  137. Epoch time: 1421838.433, per step time: 1136.561
  138. epoch: 3 step: 1251, loss is 5.5168786
  139. Epoch time: 1423009.501, per step time: 1137.498
  140. ```
  141. ## [Eval process](#contents)
  142. ### Usage
  143. You can start training using python or shell scripts. The usage of shell scripts as follows:
  144. - Ascend:
  145. ```bash
  146. sh scripts/run_eval_ascend.sh DEVICE_ID DATA_DIR CHECKPOINT_PATH
  147. ```
  148. - GPU
  149. ```bash
  150. sh scripts/run_eval_gpu.sh DATA_DIR CHECKPOINT_PATH
  151. ```
  152. ### Launch
  153. ```bash
  154. # eval example
  155. shell:
  156. Ascend:
  157. sh scripts/run_eval_ascend.sh DEVICE_ID DATA_DIR CHECKPOINT_PATH
  158. GPU:
  159. sh scripts/run_eval_gpu.sh DATA_DIR CHECKPOINT_PATH
  160. ```
  161. > checkpoint can be produced in training process.
  162. ### Result
  163. Evaluation result will be stored in the example path, you can find result like the following in `eval.log`.
  164. - Ascend
  165. ```python
  166. metric: {'Loss': 0.9849, 'Top1-Acc':0.7985, 'Top5-Acc':0.9460}
  167. ```
  168. - GPU(8p)
  169. ```python
  170. metric: {'Loss': 0.8144, 'Top1-Acc': 0.8009, 'Top5-Acc': 0.9457}
  171. ```
  172. # [Model description](#contents)
  173. ## [Performance](#contents)
  174. ### Training Performance
  175. | Parameters | Ascend | GPU |
  176. | -------------------------- | --------------------------------------------- | -------------------------------- |
  177. | Model Version | InceptionV4 | InceptionV4 |
  178. | Resource | Ascend 910; cpu 2.60GHz, 192cores; memory 755G; OS Euler2.8 | NV SMX2 V100-32G |
  179. | uploaded Date | 11/04/2020 | 03/05/2021 |
  180. | MindSpore Version | 1.0.0 | 1.0.0 |
  181. | Dataset | 1200k images | 1200K images |
  182. | Batch_size | 128 | 128 |
  183. | Training Parameters | src/config.py (Ascend) | src/config.py (GPU) |
  184. | Optimizer | RMSProp | RMSProp |
  185. | Loss Function | SoftmaxCrossEntropyWithLogits | SoftmaxCrossEntropyWithLogits |
  186. | Outputs | probability | probability |
  187. | Loss | 0.98486 | 0.8144 |
  188. | Accuracy (8p) | ACC1[79.85%] ACC5[94.60%] | ACC1[80.09%] ACC5[94.57%] |
  189. | Total time (8p) | 20h | 95h |
  190. | Params (M) | 153M | 153M |
  191. | Checkpoint for Fine tuning | 2135M | 489M |
  192. | Scripts | [inceptionv4 script](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/inceptionv4) | [inceptionv4 script](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/inceptionv4) |
  193. #### Inference Performance
  194. | Parameters | Ascend | GPU |
  195. | ------------------- | --------------------------------------------- | ---------------------------------- |
  196. | Model Version | InceptionV4 | InceptionV4 |
  197. | Resource | Ascend 910; cpu 2.60GHz, 192cores; memory 755G; OS Euler2.8 | NV SMX2 V100-32G |
  198. | Uploaded Date | 11/04/2020 | 03/05/2021 |
  199. | MindSpore Version | 1.0.0 | 1.0.0 |
  200. | Dataset | 50k images | 50K images |
  201. | Batch_size | 128 | 128 |
  202. | Outputs | probability | probability |
  203. | Accuracy | ACC1[79.85%] ACC5[94.60%] | ACC1[80.09%] ACC5[94.57%] |
  204. | Total time | 2mins | 2mins |
  205. | Model for inference | 2135M (.ckpt file) | 489M (.ckpt file) |
  206. #### Training performance results
  207. | **Ascend** | train performance |
  208. | :--------: | :---------------: |
  209. | 1p | 556 img/s |
  210. | **Ascend** | train performance |
  211. | :--------: | :---------------: |
  212. | 8p | 4430 img/s |
  213. | **GPU** | train performance |
  214. | :--------: | :---------------: |
  215. | 8p | 906 img/s |
  216. # [Description of Random Situation](#contents)
  217. In dataset.py, we set the seed inside “create_dataset" function. We also use random seed in train.py.
  218. # [ModelZoo Homepage](#contents)
  219. Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).