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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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/zh-CN/master/advanced_use/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](http://10.90.67.50/mindspore/archive/20200506/OpenSource/me_vm_x86/)
  41. - For more information, please check the resources below:
  42. - [MindSpore tutorials](https://www.mindspore.cn/tutorial/zh-CN/master/index.html)
  43. - [MindSpore API](https://www.mindspore.cn/api/zh-CN/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. 'rank' # local rank of distributed
  72. 'group_size' # world size of distributed
  73. 'work_nums' # number of workers to read the data
  74. 'decay_method' # learning rate scheduler mode
  75. "loss_scale" # loss scale
  76. 'batch_size' # input batchsize
  77. 'epoch_size' # total epoch numbers
  78. 'num_classes' # dataset class numbers
  79. 'smooth_factor' # label smoothing factor
  80. 'aux_factor' # loss factor of aux logit
  81. 'lr_init' # initiate learning rate
  82. 'lr_max' # max bound of learning rate
  83. 'lr_end' # min bound of learning rate
  84. 'warmup_epochs' # warmup epoch numbers
  85. 'weight_decay' # weight decay
  86. 'momentum' # momentum
  87. 'opt_eps' # epsilon
  88. 'keep_checkpoint_max' # max numbers to keep checkpoints
  89. 'ckpt_path' # save checkpoint path
  90. 'is_save_on_master' # save checkpoint on rank0, distributed parameters
  91. 'dropout_keep_prob' # the keep rate, between 0 and 1, e.g. keep_prob = 0.9, means dropping out 10% of input units
  92. 'has_bias' # specifies whether the layer uses a bias vector.
  93. 'amp_level' # option for argument `level` in `mindspore.amp.build_train_network`, level for mixed
  94. # precision training. Supports [O0, O2, O3].
  95. ```
  96. ## [Training process](#contents)
  97. ### Usage
  98. You can start training using python or shell scripts. The usage of shell scripts as follows:
  99. - Ascend:
  100. ```
  101. # distribute training example(8p)
  102. sh run_distribute_train.sh RANK_TABLE_FILE DATA_PATH
  103. # standalone training
  104. sh run_standalone_train.sh DEVICE_ID DATA_PATH
  105. ```
  106. > Notes:
  107. RANK_TABLE_FILE can refer to [Link](https://www.mindspore.cn/tutorial/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.
  108. - GPU:
  109. ```
  110. # distribute training example(8p)
  111. sh run_distribute_train_gpu.sh DATA_DIR
  112. # standalone training
  113. sh run_standalone_train_gpu.sh DEVICE_ID DATA_DIR
  114. ```
  115. ### Launch
  116. ```
  117. # training example
  118. python:
  119. Ascend: python train.py --dataset_path /dataset/train --platform Ascend
  120. GPU: python train.py --dataset_path /dataset/train --platform GPU
  121. shell:
  122. Ascend:
  123. # distribute training example(8p)
  124. sh run_distribute_train.sh RANK_TABLE_FILE DATA_PATH
  125. # standalone training
  126. sh run_standalone_train.sh DEVICE_ID DATA_PATH
  127. GPU:
  128. # distributed training example(8p)
  129. sh scripts/run_distribute_train_gpu.sh /dataset/train
  130. # standalone training example
  131. sh scripts/run_standalone_train_gpu.sh 0 /dataset/train
  132. ```
  133. ### Result
  134. 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.
  135. ```
  136. epoch: 0 step: 1251, loss is 5.7787247
  137. Epoch time: 360760.985, per step time: 288.378
  138. epoch: 1 step: 1251, loss is 4.392868
  139. Epoch time: 160917.911, per step time: 128.631
  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. ```
  146. sh run_eval.sh DEVICE_ID DATA_DIR PATH_CHECKPOINT
  147. ```
  148. - GPU:
  149. ```
  150. sh run_eval_gpu.sh DEVICE_ID DATA_DIR PATH_CHECKPOINT
  151. ```
  152. ### Launch
  153. ```
  154. # eval example
  155. python:
  156. Ascend: python eval.py --dataset_path DATA_DIR --checkpoint PATH_CHECKPOINT --platform Ascend
  157. GPU: python eval.py --dataset_path DATA_DIR --checkpoint PATH_CHECKPOINT --platform GPU
  158. shell:
  159. Ascend: sh run_eval.sh DEVICE_ID DATA_DIR PATH_CHECKPOINT
  160. GPU: sh run_eval_gpu.sh DEVICE_ID DATA_DIR PATH_CHECKPOINT
  161. ```
  162. > checkpoint can be produced in training process.
  163. ### Result
  164. Evaluation result will be stored in the example path, you can find result like the followings in `eval.log`.
  165. ```
  166. metric: {'Loss': 1.778, 'Top1-Acc':0.788, 'Top5-Acc':0.942}
  167. ```
  168. # [Model description](#contents)
  169. ## [Performance](#contents)
  170. ### Training Performance
  171. | Parameters | Ascend | GPU |
  172. | -------------------------- | ---------------------------------------------- | ------------------------- |
  173. | Model Version | InceptionV3 | InceptionV3 |
  174. | Resource | Ascend 910, cpu:2.60GHz 56cores, memory:314G | NV SMI V100-16G(PCIE),cpu:2.10GHz 96cores, memory:250G |
  175. | uploaded Date | 08/21/2020 | 08/21/2020 |
  176. | MindSpore Version | 0.6.0-beta | 0.6.0-beta |
  177. | Dataset | 1200k images | 1200k images |
  178. | Batch_size | 128 | 128 |
  179. | Training Parameters | src/config.py | src/config.py |
  180. | Optimizer | RMSProp | RMSProp |
  181. | Loss Function | SoftmaxCrossEntropy | SoftmaxCrossEntropy |
  182. | Outputs | probability | probability |
  183. | Loss | 1.98 | 1.98 |
  184. | Accuracy (8p) | ACC1[78.8%] ACC5[94.2%] | ACC1[78.7%] ACC5[94.1%] |
  185. | Total time (8p) | 11h | 72h |
  186. | Params (M) | 103M | 103M |
  187. | Checkpoint for Fine tuning | 313M | 312M |
  188. | 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) |
  189. #### Inference Performance
  190. | Parameters | Ascend |
  191. | ------------------- | --------------------------- |
  192. | Model Version | InceptionV3 |
  193. | Resource | Ascend 910, cpu:2.60GHz 56cores, memory:314G |
  194. | Uploaded Date | 08/22/2020 |
  195. | MindSpore Version | 0.6.0-beta |
  196. | Dataset | 50k images |
  197. | Batch_size | 128 |
  198. | Outputs | probability |
  199. | Accuracy | ACC1[78.8%] ACC5[94.2%] |
  200. | Total time | 2mins |
  201. | Model for inference | 92M (.onnx file) |
  202. # [Description of Random Situation](#contents)
  203. In dataset.py, we set the seed inside “create_dataset" function. We also use random seed in train.py.
  204. # [ModelZoo Homepage](#contents)
  205. Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).