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 11 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. # InceptionV4 for Ascend
  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)
  38. - Prepare hardware environment with Ascend processor. If you want to try Ascend , please send the [application form](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/file/other/Ascend%20Model%20Zoo%E4%BD%93%E9%AA%8C%E8%B5%84%E6%BA%90%E7%94%B3%E8%AF%B7%E8%A1%A8.docx) to ascend@huawei.com. Once approved, you can get the resources.
  39. - Framework
  40. - [MindSpore](https://www.mindspore.cn/install/en)
  41. - For more information, please check the resources below:
  42. - [MindSpore Tutorials](https://www.mindspore.cn/tutorial/training/en/master/index.html)
  43. - [MindSpore Python API](https://www.mindspore.cn/doc/api_python/en/master/index.html)
  44. # [Script description](#contents)
  45. ## [Script and sample code](#contents)
  46. ```shell
  47. .
  48. └─Inception-v4
  49. ├─README.md
  50. ├─scripts
  51. ├─run_standalone_train_ascend.sh # launch standalone training with ascend platform(1p)
  52. ├─run_distribute_train_ascend.sh # launch distributed training with ascend platform(8p)
  53. └─run_eval_ascend.sh # launch evaluating with ascend platform
  54. ├─src
  55. ├─config.py # parameter configuration
  56. ├─dataset.py # data preprocessing
  57. ├─inceptionv4.py # network definition
  58. └─callback.py # eval callback function
  59. ├─eval.py # eval net
  60. ├─export.py # export checkpoint, surpport .onnx, .air, .mindir convert
  61. └─train.py # train net
  62. ```
  63. ## [Script Parameters](#contents)
  64. ```python
  65. Major parameters in train.py and config.py are:
  66. 'is_save_on_master' # save checkpoint only on master device
  67. 'batch_size' # input batchsize
  68. 'epoch_size' # total epoch numbers
  69. 'num_classes' # dataset class numbers
  70. 'work_nums' # number of workers to read data
  71. 'loss_scale' # loss scale
  72. 'smooth_factor' # label smoothing factor
  73. 'weight_decay' # weight decay
  74. 'momentum' # momentum
  75. 'amp_level' # precision training, Supports [O0, O2, O3]
  76. 'decay' # decay used in optimize function
  77. 'epsilon' # epsilon used in iptimize function
  78. 'keep_checkpoint_max' # max numbers to keep checkpoints
  79. 'save_checkpoint_epochs' # save checkpoints per n epoch
  80. 'lr_init' # init leaning rate
  81. 'lr_end' # end of learning rate
  82. 'lr_max' # max bound of learning rate
  83. 'warmup_epochs' # warmup epoch numbers
  84. 'start_epoch' # number of start epoch range[1, epoch_size]
  85. ```
  86. ## [Training process](#contents)
  87. ### Usage
  88. You can start training using python or shell scripts. The usage of shell scripts as follows:
  89. - Ascend:
  90. ```bash
  91. # distribute training example(8p)
  92. sh scripts/run_distribute_train_ascend.sh RANK_TABLE_FILE DATA_PATH DATA_DIR
  93. # standalone training
  94. sh scripts/run_standalone_train_ascend.sh DEVICE_ID DATA_DIR
  95. ```
  96. > Notes:
  97. > 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.
  98. >
  99. > 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`
  100. ### Launch
  101. ```bash
  102. # training example
  103. shell:
  104. Ascend:
  105. # distribute training example(8p)
  106. sh scripts/run_distribute_train_ascend.sh RANK_TABLE_FILE DATA_PATH DATA_DIR
  107. # standalone training
  108. sh scripts/run_standalone_train_ascend.sh DEVICE_ID DATA_DIR
  109. ```
  110. ### Result
  111. 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.
  112. ```python
  113. epoch: 1 step: 1251, loss is 5.4833196
  114. Epoch time: 520274.060, per step time: 415.887
  115. epoch: 2 step: 1251, loss is 4.093194
  116. Epoch time: 288520.628, per step time: 230.632
  117. epoch: 3 step: 1251, loss is 3.6242008
  118. Epoch time: 288507.506, per step time: 230.622
  119. ```
  120. ## [Eval process](#contents)
  121. ### Usage
  122. You can start training using python or shell scripts. The usage of shell scripts as follows:
  123. - Ascend:
  124. ```bash
  125. sh scripts/run_eval_ascend.sh DEVICE_ID DATA_DIR CHECKPOINT_PATH
  126. ```
  127. ### Launch
  128. ```bash
  129. # eval example
  130. shell:
  131. Ascend:
  132. sh scripts/run_eval_ascend.sh DEVICE_ID DATA_DIR CHECKPOINT_PATH
  133. ```
  134. > checkpoint can be produced in training process.
  135. ### Result
  136. Evaluation result will be stored in the example path, you can find result like the following in `eval.log`.
  137. ```python
  138. metric: {'Loss': 0.9849, 'Top1-Acc':0.7985, 'Top5-Acc':0.9460}
  139. ```
  140. # [Model description](#contents)
  141. ## [Performance](#contents)
  142. ### Training Performance
  143. | Parameters | Ascend |
  144. | -------------------------- | ------------------------------------------------------------ |
  145. | Model Version | InceptionV4 |
  146. | Resource | Ascend 910, cpu:2.60GHz 192cores, memory:755G |
  147. | uploaded Date | 11/04/2020 |
  148. | MindSpore Version | 1.0.0 |
  149. | Dataset | 1200k images |
  150. | Batch_size | 128 |
  151. | Training Parameters | src/config.py |
  152. | Optimizer | RMSProp |
  153. | Loss Function | SoftmaxCrossEntropyWithLogits |
  154. | Outputs | probability |
  155. | Loss | 0.98486 |
  156. | Accuracy (8p) | ACC1[79.85%] ACC5[94.60%] |
  157. | Total time (8p) | 20h |
  158. | Params (M) | 153M |
  159. | Checkpoint for Fine tuning | 2135M |
  160. | Scripts | [inceptionv4 script](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/inceptionv4) |
  161. #### Inference Performance
  162. | Parameters | Ascend |
  163. | ------------------- | --------------------------- |
  164. | Model Version | InceptionV4 |
  165. | Resource | Ascend 910, cpu:2.60GHz 192cores, memory:755G |
  166. | Uploaded Date | 11/04/2020 |
  167. | MindSpore Version | 1.0.0 |
  168. | Dataset | 50k images |
  169. | Batch_size | 128 |
  170. | Outputs | probability |
  171. | Accuracy | ACC1[79.85%] ACC5[94.60%] |
  172. | Total time | 2mins |
  173. | Model for inference | 2135M (.ckpt file) |
  174. #### Training performance results
  175. | **Ascend** | train performance |
  176. | :--------: | :---------------: |
  177. | 1p | 556 img/s |
  178. | **Ascend** | train performance |
  179. | :--------: | :---------------: |
  180. | 8p | 4430 img/s |
  181. # [Description of Random Situation](#contents)
  182. In dataset.py, we set the seed inside “create_dataset" function. We also use random seed in train.py.
  183. # [ModelZoo Homepage](#contents)
  184. Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).