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

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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. - [Training Performance](#evaluation-performance)
  16. - [Inference Performance](#evaluation-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/GPU)
  38. - Prepare hardware environment with Ascend or GPU 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_standalone_train_gpu.sh # launch standalone training with gpu platform(1p)
  53. ├─run_distribute_train.sh # launch distributed training with ascend platform(8p)
  54. ├─run_distribute_train_gpu.sh # launch distributed training with gpu platform(8p)
  55. ├─run_eval.sh # launch evaluating with ascend platform
  56. └─run_eval_gpu.sh # launch evaluating with gpu platform
  57. ├─src
  58. ├─config.py # parameter configuration
  59. ├─dataset.py # data preprocessing
  60. ├─inception_v3.py # network definition
  61. ├─loss.py # Customized CrossEntropy loss function
  62. ├─lr_generator.py # learning rate generator
  63. ├─eval.py # eval net
  64. ├─export.py # convert checkpoint
  65. └─train.py # train net
  66. ```
  67. ## [Script Parameters](#contents)
  68. ```python
  69. Major parameters in train.py and config.py are:
  70. 'random_seed' # fix random seed
  71. 'work_nums' # number of workers to read the data
  72. 'decay_method' # learning rate scheduler mode
  73. "loss_scale" # loss scale
  74. 'batch_size' # input batchsize
  75. 'epoch_size' # total epoch numbers
  76. 'num_classes' # dataset class numbers
  77. 'smooth_factor' # label smoothing factor
  78. 'aux_factor' # loss factor of aux logit
  79. 'lr_init' # initiate learning rate
  80. 'lr_max' # max bound of learning rate
  81. 'lr_end' # min bound of learning rate
  82. 'warmup_epochs' # warmup epoch numbers
  83. 'weight_decay' # weight decay
  84. 'momentum' # momentum
  85. 'opt_eps' # epsilon
  86. 'keep_checkpoint_max' # max numbers to keep checkpoints
  87. 'ckpt_path' # save checkpoint path
  88. 'is_save_on_master' # save checkpoint on rank0, distributed parameters
  89. 'dropout_keep_prob' # the keep rate, between 0 and 1, e.g. keep_prob = 0.9, means dropping out 10% of input units
  90. 'has_bias' # specifies whether the layer uses a bias vector.
  91. 'amp_level' # option for argument `level` in `mindspore.amp.build_train_network`, level for mixed
  92. # precision training. Supports [O0, O2, O3].
  93. ```
  94. ## [Training process](#contents)
  95. ### Usage
  96. You can start training using python or shell scripts. The usage of shell scripts as follows:
  97. - Ascend:
  98. ```shell
  99. # distribute training example(8p)
  100. sh scripts/run_distribute_train.sh RANK_TABLE_FILE DATA_PATH
  101. # standalone training
  102. sh scripts/run_standalone_train.sh DEVICE_ID DATA_PATH
  103. ```
  104. > 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.
  105. >
  106. > 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`
  107. - GPU:
  108. ```python
  109. # distribute training example(8p)
  110. sh scripts/run_distribute_train_gpu.sh DATA_DIR
  111. # standalone training
  112. sh scripts/run_standalone_train_gpu.sh DEVICE_ID DATA_DIR
  113. ```
  114. ### Launch
  115. ```python
  116. # training example
  117. python:
  118. Ascend: python train.py --dataset_path /dataset/train --platform Ascend
  119. GPU: python train.py --dataset_path /dataset/train --platform GPU
  120. shell:
  121. Ascend:
  122. # distribute training example(8p)
  123. sh scripts/run_distribute_train.sh RANK_TABLE_FILE DATA_PATH
  124. # standalone training
  125. sh scripts/run_standalone_train.sh DEVICE_ID DATA_PATH
  126. GPU:
  127. # distributed training example(8p)
  128. sh scripts/run_distribute_train_gpu.sh /dataset/train
  129. # standalone training example
  130. sh scripts/run_standalone_train_gpu.sh 0 /dataset/train
  131. ```
  132. ### Result
  133. 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.
  134. ```python
  135. epoch: 0 step: 1251, loss is 5.7787247
  136. epoch time: 360760.985 ms, per step time: 288.378 ms
  137. epoch: 1 step: 1251, loss is 4.392868
  138. epoch time: 160917.911 ms, per step time: 128.631 ms
  139. ```
  140. ## [Eval process](#contents)
  141. ### Usage
  142. You can start training using python or shell scripts. The usage of shell scripts as follows:
  143. - Ascend:
  144. ```python
  145. sh scripts/run_eval.sh DEVICE_ID DATA_DIR PATH_CHECKPOINT
  146. ```
  147. - GPU:
  148. ```python
  149. sh scripts/run_eval_gpu.sh DEVICE_ID DATA_DIR PATH_CHECKPOINT
  150. ```
  151. ### Launch
  152. ```python
  153. # eval example
  154. python:
  155. Ascend: python eval.py --dataset_path DATA_DIR --checkpoint PATH_CHECKPOINT --platform Ascend
  156. GPU: python eval.py --dataset_path DATA_DIR --checkpoint PATH_CHECKPOINT --platform GPU
  157. shell:
  158. Ascend: sh scripts/run_eval.sh DEVICE_ID DATA_DIR PATH_CHECKPOINT
  159. GPU: sh scripts/run_eval_gpu.sh DEVICE_ID DATA_DIR PATH_CHECKPOINT
  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 followings in `eval.log`.
  164. ```python
  165. metric: {'Loss': 1.778, 'Top1-Acc':0.788, 'Top5-Acc':0.942}
  166. ```
  167. # [Model description](#contents)
  168. ## [Performance](#contents)
  169. ### Training Performance
  170. | Parameters | Ascend | GPU |
  171. | -------------------------- | ---------------------------------------------- | ------------------------- |
  172. | Model Version | InceptionV3 | InceptionV3 |
  173. | Resource | Ascend 910, cpu:2.60GHz 192cores, memory:755G | NV SMI V100-16G(PCIE),cpu:2.10GHz 96cores, memory:250G |
  174. | uploaded Date | 08/21/2020 | 08/21/2020 |
  175. | MindSpore Version | 0.6.0-beta | 0.6.0-beta |
  176. | Dataset | 1200k images | 1200k images |
  177. | Batch_size | 128 | 128 |
  178. | Training Parameters | src/config.py | src/config.py |
  179. | Optimizer | RMSProp | RMSProp |
  180. | Loss Function | SoftmaxCrossEntropy | SoftmaxCrossEntropy |
  181. | Outputs | probability | probability |
  182. | Loss | 1.98 | 1.98 |
  183. | Accuracy (8p) | ACC1[78.8%] ACC5[94.2%] | ACC1[78.7%] ACC5[94.1%] |
  184. | Total time (8p) | 11h | 72h |
  185. | Params (M) | 103M | 103M |
  186. | Checkpoint for Fine tuning | 313M | 312M |
  187. | Scripts | [inceptionv3 script](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/inceptionv3) | [inceptionv3 script](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/inceptionv3) |
  188. #### Inference Performance
  189. | Parameters | Ascend |
  190. | ------------------- | --------------------------- |
  191. | Model Version | InceptionV3 |
  192. | Resource | Ascend 910, cpu:2.60GHz 192cores, memory:755G |
  193. | Uploaded Date | 08/22/2020 |
  194. | MindSpore Version | 0.6.0-beta |
  195. | Dataset | 50k images |
  196. | Batch_size | 128 |
  197. | Outputs | probability |
  198. | Accuracy | ACC1[78.8%] ACC5[94.2%] |
  199. | Total time | 2mins |
  200. | Model for inference | 92M (.onnx file) |
  201. # [Description of Random Situation](#contents)
  202. In dataset.py, we set the seed inside “create_dataset" function. We also use random seed in train.py.
  203. # [ModelZoo Homepage](#contents)
  204. Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).