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

5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. # Contents
  2. - [InceptionV3 Description](#InceptionV3-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. - [Evaluation Performance](#evaluation-performance)
  16. - [Inference Performance](#inference-performance)
  17. - [Description of Random Situation](#description-of-random-situation)
  18. - [ModelZoo Homepage](#modelzoo-homepage)
  19. # [InceptionV3 Description](#contents)
  20. InceptionV3 by Google is the 3rd version in a series of Deep Learning Convolutional Architectures. Inception v3 mainly focuses on burning less computational power by modifying the previous Inception architectures. This idea was proposed in the paper Rethinking the Inception Architecture for Computer Vision, published in 2015.
  21. [Paper](https://arxiv.org/pdf/1512.00567.pdf) Min Sun, Ali Farhadi, Steve Seitz. Ranking Domain-Specific Highlights by Analyzing Edited Videos[J]. 2014.
  22. # [Model architecture](#contents)
  23. The overall network architecture of InceptionV3 is show below:
  24. [Link](https://arxiv.org/pdf/1512.00567.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-v3
  49. ├─README.md
  50. ├─scripts
  51. ├─run_standalone_train.sh # launch standalone training with ascend platform(1p)
  52. ├─run_distribute_train.sh # launch distributed training with ascend platform(8p)
  53. └─run_eval.sh # launch evaluating with ascend platform
  54. ├─src
  55. ├─config.py # parameter configuration
  56. ├─dataset.py # data preprocessing
  57. ├─inception_v3.py # network definition
  58. ├─loss.py # Customized CrossEntropy loss function
  59. ├─lr_generator.py # learning rate generator
  60. ├─eval.py # eval net
  61. ├─export.py # convert checkpoint
  62. └─train.py # train net
  63. ```
  64. ## [Script Parameters](#contents)
  65. ```python
  66. Major parameters in train.py and config.py are:
  67. 'random_seed' # fix random seed
  68. 'work_nums' # number of workers to read the data
  69. 'decay_method' # learning rate scheduler mode
  70. "loss_scale" # loss scale
  71. 'batch_size' # input batchsize
  72. 'epoch_size' # total epoch numbers
  73. 'num_classes' # dataset class numbers
  74. 'smooth_factor' # label smoothing factor
  75. 'aux_factor' # loss factor of aux logit
  76. 'lr_init' # initiate learning rate
  77. 'lr_max' # max bound of learning rate
  78. 'lr_end' # min bound of learning rate
  79. 'warmup_epochs' # warmup epoch numbers
  80. 'weight_decay' # weight decay
  81. 'momentum' # momentum
  82. 'opt_eps' # epsilon
  83. 'keep_checkpoint_max' # max numbers to keep checkpoints
  84. 'ckpt_path' # save checkpoint path
  85. 'is_save_on_master' # save checkpoint on rank0, distributed parameters
  86. 'dropout_keep_prob' # the keep rate, between 0 and 1, e.g. keep_prob = 0.9, means dropping out 10% of input units
  87. 'has_bias' # specifies whether the layer uses a bias vector.
  88. 'amp_level' # option for argument `level` in `mindspore.amp.build_train_network`, level for mixed
  89. # precision training. Supports [O0, O2, O3].
  90. ```
  91. ## [Training process](#contents)
  92. ### Usage
  93. You can start training using python or shell scripts. The usage of shell scripts as follows:
  94. - Ascend:
  95. ```shell
  96. # distribute training(8p)
  97. sh scripts/run_distribute_train.sh RANK_TABLE_FILE DATA_PATH
  98. # standalone training
  99. sh scripts/run_standalone_train.sh DEVICE_ID DATA_PATH
  100. ```
  101. > Notes: 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 InceptionV3, 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.
  102. >
  103. > 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`
  104. ### Launch
  105. ```python
  106. # training example
  107. python:
  108. Ascend: python train.py --dataset_path DATA_PATH --platform Ascend
  109. shell:
  110. Ascend:
  111. # distribute training example(8p)
  112. sh scripts/run_distribute_train.sh RANK_TABLE_FILE DATA_PATH
  113. # standalone training example
  114. sh scripts/run_standalone_train.sh DEVICE_ID DATA_PATH
  115. ```
  116. ### Result
  117. Training result will be stored in the example path. Checkpoints will be stored at `. /checkpoint` by default, and training log will be redirected to `./log.txt` like followings.
  118. ```python
  119. epoch: 0 step: 1251, loss is 5.7787247
  120. epoch time: 360760.985 ms, per step time: 288.378 ms
  121. epoch: 1 step: 1251, loss is 4.392868
  122. epoch time: 160917.911 ms, per step time: 128.631 ms
  123. ```
  124. ## [Eval process](#contents)
  125. ### Usage
  126. You can start training using python or shell scripts. The usage of shell scripts as follows:
  127. - Ascend:
  128. ```python
  129. sh scripts/run_eval.sh DEVICE_ID DATA_PATH PATH_CHECKPOINT
  130. ```
  131. ### Launch
  132. ```python
  133. # eval example
  134. python:
  135. Ascend: python eval.py --dataset_path DATA_PATH --checkpoint PATH_CHECKPOINT --platform Ascend
  136. shell:
  137. Ascend: sh scripts/run_eval.sh DEVICE_ID DATA_PATH PATH_CHECKPOINT
  138. ```
  139. > checkpoint can be produced in training process.
  140. ### Result
  141. Evaluation result will be stored in the example path, you can find result like the followings in `eval.log`.
  142. ```python
  143. metric: {'Loss': 1.778, 'Top1-Acc':0.788, 'Top5-Acc':0.942}
  144. ```
  145. # [Model description](#contents)
  146. ## [Performance](#contents)
  147. ### Evaluation Performance
  148. | Parameters | Ascend |
  149. | -------------------------- | ---------------------------------------------- |
  150. | Model Version | InceptionV3 |
  151. | Resource | Ascend 910, cpu:2.60GHz 192cores, memory:755G |
  152. | uploaded Date | 08/21/2020 |
  153. | MindSpore Version | 0.6.0-beta |
  154. | Dataset | 1200k images |
  155. | Batch_size | 128 |
  156. | Training Parameters | src/config.py |
  157. | Optimizer | RMSProp |
  158. | Loss Function | SoftmaxCrossEntropy |
  159. | Outputs | probability |
  160. | Loss | 1.98 |
  161. | Total time (8p) | 11h |
  162. | Params (M) | 103M |
  163. | Checkpoint for Fine tuning | 313M |
  164. | Model for inference | 92M (.onnx file) |
  165. | Speed | 1pc:1050 img/s;8pc:8000 img/s |
  166. | Scripts | [inceptionv3 script](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/inceptionv3) |
  167. ### Inference Performance
  168. | Parameters | Ascend |
  169. | ------------------- | --------------------------- |
  170. | Model Version | InceptionV3 |
  171. | Resource | Ascend 910, cpu:2.60GHz 192cores, memory:755G |
  172. | Uploaded Date | 08/22/2020 |
  173. | MindSpore Version | 0.6.0-beta |
  174. | Dataset | 50k images |
  175. | Batch_size | 128 |
  176. | Outputs | probability |
  177. | Accuracy | ACC1[78.8%] ACC5[94.2%] |
  178. | Total time | 2mins |
  179. # [Description of Random Situation](#contents)
  180. In dataset.py, we set the seed inside “create_dataset" function. We also use random seed in train.py.
  181. # [ModelZoo Homepage](#contents)
  182. Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).