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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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. Dataset used: [CIFAR-10](http://www.cs.toronto.edu/~kriz/cifar.html)
  33. - Dataset size: 175M, 60,000 32\*32 colorful images in 10 classes
  34. - Train: 146M, 50,000 images
  35. - Test: 29M, 10,000 images
  36. - Data format:binary files
  37. - Note:Data will be processed in src/dataset.py
  38. # [Features](#contents)
  39. ## [Mixed Precision(Ascend)](#contents)
  40. 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.
  41. 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’.
  42. # [Environment Requirements](#contents)
  43. - Hardware(Ascend)
  44. - Prepare hardware environment with Ascend processor.
  45. - Framework
  46. - [MindSpore](https://www.mindspore.cn/install/en)
  47. - For more information, please check the resources below:
  48. - [MindSpore Tutorials](https://www.mindspore.cn/tutorial/training/en/master/index.html)
  49. - [MindSpore Python API](https://www.mindspore.cn/doc/api_python/en/master/index.html)
  50. # [Script description](#contents)
  51. ## [Script and sample code](#contents)
  52. ```shell
  53. .
  54. └─Inception-v3
  55. ├─README.md
  56. ├─scripts
  57. ├─run_standalone_train_cpu.sh # launch standalone training with cpu platform
  58. ├─run_standalone_train_gpu.sh # launch standalone training with gpu platform(1p)
  59. ├─run_distribute_train_gpu.sh # launch distributed training with gpu platform(8p)
  60. ├─run_standalone_train.sh # launch standalone training with ascend platform(1p)
  61. ├─run_distribute_train.sh # launch distributed training with ascend platform(8p)
  62. ├─run_eval_cpu.sh # launch evaluation with cpu platform
  63. ├─run_eval_gpu.sh # launch evaluation with gpu platform
  64. └─run_eval.sh # launch evaluating with ascend platform
  65. ├─src
  66. ├─config.py # parameter configuration
  67. ├─dataset.py # data preprocessing
  68. ├─inception_v3.py # network definition
  69. ├─loss.py # Customized CrossEntropy loss function
  70. ├─lr_generator.py # learning rate generator
  71. ├─eval.py # eval net
  72. ├─export.py # convert checkpoint
  73. └─train.py # train net
  74. ```
  75. ## [Script Parameters](#contents)
  76. ```python
  77. Major parameters in train.py and config.py are:
  78. 'random_seed' # fix random seed
  79. 'work_nums' # number of workers to read the data
  80. 'decay_method' # learning rate scheduler mode
  81. "loss_scale" # loss scale
  82. 'batch_size' # input batchsize
  83. 'epoch_size' # total epoch numbers
  84. 'num_classes' # dataset class numbers
  85. 'ds_type' # dataset type, such as: imagenet, cifar10
  86. 'ds_sink_mode' # whether enable dataset sink mode
  87. 'smooth_factor' # label smoothing factor
  88. 'aux_factor' # loss factor of aux logit
  89. 'lr_init' # initiate learning rate
  90. 'lr_max' # max bound of learning rate
  91. 'lr_end' # min bound of learning rate
  92. 'warmup_epochs' # warmup epoch numbers
  93. 'weight_decay' # weight decay
  94. 'momentum' # momentum
  95. 'opt_eps' # epsilon
  96. 'keep_checkpoint_max' # max numbers to keep checkpoints
  97. 'ckpt_path' # save checkpoint path
  98. 'is_save_on_master' # save checkpoint on rank0, distributed parameters
  99. 'dropout_keep_prob' # the keep rate, between 0 and 1, e.g. keep_prob = 0.9, means dropping out 10% of input units
  100. 'has_bias' # specifies whether the layer uses a bias vector.
  101. 'amp_level' # option for argument `level` in `mindspore.amp.build_train_network`, level for mixed
  102. # precision training. Supports [O0, O2, O3].
  103. ```
  104. ## [Training process](#contents)
  105. ### Usage
  106. You can start training using python or shell scripts. The usage of shell scripts as follows:
  107. - Ascend:
  108. ```shell
  109. # distribute training(8p)
  110. sh scripts/run_distribute_train.sh RANK_TABLE_FILE DATA_PATH
  111. # standalone training
  112. sh scripts/run_standalone_train.sh DEVICE_ID DATA_PATH
  113. ```
  114. - CPU:
  115. ```shell
  116. # standalone training
  117. sh scripts/run_standalone_train_cpu.sh DATA_PATH
  118. ```
  119. > 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.
  120. >
  121. > 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`
  122. ### Launch
  123. ```python
  124. # training example
  125. python:
  126. Ascend: python train.py --dataset_path DATA_PATH --platform Ascend
  127. CPU: python train.py --dataset_path DATA_PATH --platform CPU
  128. shell:
  129. Ascend:
  130. # distribute training example(8p)
  131. sh scripts/run_distribute_train.sh RANK_TABLE_FILE DATA_PATH
  132. # standalone training example
  133. sh scripts/run_standalone_train.sh DEVICE_ID DATA_PATH
  134. CPU:
  135. sh script/run_standalone_train_cpu.sh DATA_PATH
  136. ```
  137. ### Result
  138. 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.
  139. #### Ascend
  140. ```python
  141. epoch: 0 step: 1251, loss is 5.7787247
  142. epoch time: 360760.985 ms, per step time: 288.378 ms
  143. epoch: 1 step: 1251, loss is 4.392868
  144. epoch time: 160917.911 ms, per step time: 128.631 ms
  145. ```
  146. #### CPU
  147. ```bash
  148. epoch: 1 step: 390, loss is 2.7072601
  149. epoch time: 6334572.124 ms, per step time: 16242.493 ms
  150. epoch: 2 step: 390, loss is 2.5908582
  151. epoch time: 6217897.644 ms, per step time: 15943.327 ms
  152. epoch: 3 step: 390, loss is 2.5612416
  153. epoch time: 6358482.104 ms, per step time: 16303.800 ms
  154. ...
  155. ```
  156. ## [Eval process](#contents)
  157. ### Usage
  158. You can start training using python or shell scripts. The usage of shell scripts as follows:
  159. - Ascend:
  160. ```python
  161. sh scripts/run_eval.sh DEVICE_ID DATA_PATH PATH_CHECKPOINT
  162. ```
  163. - CPU:
  164. ```python
  165. sh scripts/run_eval_cpu.sh DATA_PATH PATH_CHECKPOINT
  166. ```
  167. ### Launch
  168. ```python
  169. # eval example
  170. python:
  171. Ascend: python eval.py --dataset_path DATA_PATH --checkpoint PATH_CHECKPOINT --platform Ascend
  172. CPU: python eval.py --dataset_path DATA_PATH --checkpoint PATH_CHECKPOINT --platform CPU
  173. shell:
  174. Ascend: sh scripts/run_eval.sh DEVICE_ID DATA_PATH PATH_CHECKPOINT
  175. CPU: sh scripts/run_eval_cpu.sh DATA_PATH PATH_CHECKPOINT
  176. ```
  177. > checkpoint can be produced in training process.
  178. ### Result
  179. Evaluation result will be stored in the example path, you can find result like the followings in `eval.log`.
  180. ```python
  181. metric: {'Loss': 1.778, 'Top1-Acc':0.788, 'Top5-Acc':0.942}
  182. ```
  183. # [Model description](#contents)
  184. ## [Performance](#contents)
  185. ### Evaluation Performance
  186. | Parameters | Ascend |
  187. | -------------------------- | ---------------------------------------------- |
  188. | Model Version | InceptionV3 |
  189. | Resource | Ascend 910; cpu 2.60GHz, 192cores; memory 755G; OS Euler2.8 |
  190. | uploaded Date | 08/21/2020 |
  191. | MindSpore Version | 0.6.0-beta |
  192. | Dataset | 1200k images |
  193. | Batch_size | 128 |
  194. | Training Parameters | src/config.py |
  195. | Optimizer | RMSProp |
  196. | Loss Function | SoftmaxCrossEntropy |
  197. | Outputs | probability |
  198. | Loss | 1.98 |
  199. | Total time (8p) | 11h |
  200. | Params (M) | 103M |
  201. | Checkpoint for Fine tuning | 313M |
  202. | Model for inference | 92M (.onnx file) |
  203. | Speed | 1pc:1050 img/s;8pc:8000 img/s |
  204. | Scripts | [inceptionv3 script](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/inceptionv3) |
  205. ### Inference Performance
  206. | Parameters | Ascend |
  207. | ------------------- | --------------------------- |
  208. | Model Version | InceptionV3 |
  209. | Resource | Ascend 910; cpu 2.60GHz, 192cores; memory 755G; OS Euler2.8 |
  210. | Uploaded Date | 08/22/2020 |
  211. | MindSpore Version | 0.6.0-beta |
  212. | Dataset | 50k images |
  213. | Batch_size | 128 |
  214. | Outputs | probability |
  215. | Accuracy | ACC1[78.8%] ACC5[94.2%] |
  216. | Total time | 2mins |
  217. # [Description of Random Situation](#contents)
  218. In dataset.py, we set the seed inside “create_dataset" function. We also use random seed in train.py.
  219. # [ModelZoo Homepage](#contents)
  220. Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).