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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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.
  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/1905.02244)
  25. # [Dataset](#contents)
  26. Dataset used can refer to paper.
  27. - Dataset size: ~125G, 1.2W colorful images in 1000 classes
  28. - Train: 120G, 1.2W images
  29. - Test: 5G, 50000 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_for_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_for_gpu.sh # launch distributed training with gpu platform(8p)
  55. ├─run_eval.sh # launch evaluating with ascend platform
  56. └─run_eval_for_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': 1, # fix random seed
  71. 'rank': 0, # local rank of distributed
  72. 'group_size': 1, # world size of distributed
  73. 'work_nums': 8, # number of workers to read the data
  74. 'decay_method': 'cosine', # learning rate scheduler mode
  75. "loss_scale": 1, # loss scale
  76. 'batch_size': 128, # input batchsize
  77. 'epoch_size': 250, # total epoch numbers
  78. 'num_classes': 1000, # dataset class numbers
  79. 'smooth_factor': 0.1, # label smoothing factor
  80. 'aux_factor': 0.2, # loss factor of aux logit
  81. 'lr_init': 0.00004, # initiate learning rate
  82. 'lr_max': 0.4, # max bound of learning rate
  83. 'lr_end': 0.000004, # min bound of learning rate
  84. 'warmup_epochs': 1, # warmup epoch numbers
  85. 'weight_decay': 0.00004, # weight decay
  86. 'momentum': 0.9, # momentum
  87. 'opt_eps': 1.0, # epsilon
  88. 'keep_checkpoint_max': 100, # max numbers to keep checkpoints
  89. 'ckpt_path': './checkpoint/', # save checkpoint path
  90. 'is_save_on_master': 1 # save checkpoint on rank0, distributed parameters
  91. ```
  92. ## [Training process](#contents)
  93. ### Usage
  94. You can start training using python or shell scripts. The usage of shell scripts as follows:
  95. - Ascend:
  96. ```
  97. # distribute training example(8p)
  98. sh run_distribute_train.sh RANK_TABLE_FILE DATA_PATH
  99. # standalone training
  100. sh run_standalone_train.sh DEVICE_ID DATA_PATH
  101. ```
  102. - GPU:
  103. ```
  104. # distribute training example(8p)
  105. sh run_distribute_train_for_gpu.sh DATA_DIR
  106. # standalone training
  107. sh run_standalone_train_for_gpu.sh DEVICE_ID DATA_DIR
  108. ```
  109. ### Launch
  110. ```
  111. # training example
  112. python:
  113. Ascend: python train.py --dataset_path /dataset/train --platform Ascend
  114. GPU: python train.py --dataset_path /dataset/train --platform GPU
  115. shell:
  116. # distributed training example(8p) for GPU
  117. sh scripts/run_distribute_train_for_gpu.sh /dataset/train
  118. # standalone training example for GPU
  119. sh scripts/run_standalone_train_for_gpu.sh 0 /dataset/train
  120. ```
  121. ### Result
  122. 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.
  123. ```
  124. epoch: 0 step: 1251, loss is 5.7787247
  125. Epoch time: 360760.985, per step time: 288.378
  126. epoch: 1 step: 1251, loss is 4.392868
  127. Epoch time: 160917.911, per step time: 128.631
  128. ```
  129. ## [Eval process](#contents)
  130. ### Usage
  131. You can start training using python or shell scripts. The usage of shell scripts as follows:
  132. - Ascend: sh run_eval.sh DEVICE_ID DATA_DIR PATH_CHECKPOINT
  133. - GPU: sh run_eval_for_gpu.sh DEVICE_ID DATA_DIR PATH_CHECKPOINT
  134. ### Launch
  135. ```
  136. # eval example
  137. python:
  138. Ascend: python eval.py --dataset_path DATA_DIR --checkpoint PATH_CHECKPOINT --platform Ascend
  139. GPU: python eval.py --dataset_path DATA_DIR --checkpoint PATH_CHECKPOINT --platform GPU
  140. shell:
  141. Ascend: sh run_eval.sh DEVICE_ID DATA_DIR PATH_CHECKPOINT
  142. GPU: sh run_eval_for_gpu.sh DEVICE_ID DATA_DIR PATH_CHECKPOINT
  143. ```
  144. > checkpoint can be produced in training process.
  145. ### Result
  146. Evaluation result will be stored in the example path, you can find result like the followings in `log.txt`.
  147. ```
  148. metric: {'Loss': 1.778, 'Top1-Acc':0.788, 'Top5-Acc':0.942}
  149. ```
  150. # [Model description](#contents)
  151. ## [Performance](#contents)
  152. ### Training Performance
  153. | Parameters | InceptionV3 | |
  154. | -------------------------- | ---------------------------------------------------------- | ------------------------- |
  155. | Model Version | | |
  156. | Resource | Ascend 910, cpu:2.60GHz 56cores, memory:314G | NV SMX2 V100-32G |
  157. | uploaded Date | 08/21/2020 | 08/21/2020 |
  158. | MindSpore Version | 0.6.0-beta | 0.6.0-beta |
  159. | Training Parameters | src/config.py | src/config.py |
  160. | Optimizer | RMSProp | RMSProp |
  161. | Loss Function | SoftmaxCrossEntropy | SoftmaxCrossEntropy |
  162. | outputs | probability | probability |
  163. | Loss | 1.98 | 1.98 |
  164. | Accuracy | ACC1[78.8%] ACC5[94.2%] | ACC1[78.7%] ACC5[94.1%] |
  165. | Total time | 11h | 72h |
  166. | Params (M) | 103M | 103M |
  167. | Checkpoint for Fine tuning | 313M | 312.41M |
  168. #### Inference Performance
  169. | Parameters | InceptionV3 |
  170. | ------------------- | --------------------------- |
  171. | Model Version | |
  172. | Resource | Ascend 910 |
  173. | Uploaded Date | 08/22/2020 (month/day/year) |
  174. | MindSpore Version | 0.6.0-beta |
  175. | Dataset | 50,000 images |
  176. | batch_size | 128 |
  177. | outputs | probability |
  178. | Accuracy | ACC1[78.8%] ACC5[94.2%] |
  179. | Total time | 2mins |
  180. | Model for inference | 92M (.onnx file) |
  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).