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

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. # Contents
  2. - [resnet50 Description](#resnet50-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. - [Model Description](#model-description)
  13. - [Performance](#performance)
  14. - [Training Performance](#training-performance)
  15. - [Evaluation Performance](#evaluation-performance)
  16. - [Description of Random Situation](#description-of-random-situation)
  17. - [ModelZoo Homepage](#modelzoo-homepage)
  18. # [resnet50 Description](#contents)
  19. ResNet-50 is a convolutional neural network that is 50 layers deep, which can classify ImageNet image to 1000 object categories with 76% accuracy.
  20. [Paper](https://arxiv.org/abs/1512.03385) Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun."Deep Residual Learning for Image Recognition." He, Kaiming , et al. "Deep Residual Learning for Image Recognition." IEEE Conference on Computer Vision & Pattern Recognition IEEE Computer Society, 2016.
  21. This is the quantitative network of Resnet50.
  22. # [Model architecture](#contents)
  23. The overall network architecture of Resnet50 is show below:
  24. [Link](https://arxiv.org/pdf/1512.03385.pdf)
  25. # [Dataset](#contents)
  26. Dataset used: [imagenet](http://www.image-net.org/)
  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](#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
  38. - Prepare hardware environment with Ascend. 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/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. ```python
  47. ├── resnet50_quant
  48. ├── Readme.md # descriptions about Resnet50-Quant
  49. ├── scripts
  50. │ ├──run_train.sh # shell script for train on Ascend
  51. │ ├──run_infer.sh # shell script for evaluation on Ascend
  52. ├── model
  53. │ ├──resnet_quant.py # define the network model of resnet50-quant
  54. ├── src
  55. │ ├──config.py # parameter configuration
  56. │ ├──dataset.py # creating dataset
  57. │ ├──launch.py # start python script
  58. │ ├──lr_generator.py # learning rate config
  59. │ ├──crossentropy.py # define the crossentropy of resnet50-quant
  60. ├── train.py # training script
  61. ├── eval.py # evaluation script
  62. ```
  63. ## [Training process](#contents)
  64. ### Usage
  65. - Ascend: sh run_train.sh Ascend [RANK_TABLE_FILE] [DATASET_PATH] [PRETRAINED_CKPT_PATH]\(optional)
  66. ### Launch
  67. ```
  68. # training example
  69. Ascend: bash run_train.sh Ascend ~/hccl_4p_0123_x.x.x.x.json ~/imagenet/train/
  70. ```
  71. ### Result
  72. Training result will be stored in the example path. Checkpoints will be stored at `./train/device$i/` by default, and training log will be redirected to `./train/device$i/train.log` like followings.
  73. ```
  74. epoch: 1 step: 5004, loss is 4.8995576
  75. epoch: 2 step: 5004, loss is 3.9235563
  76. epoch: 3 step: 5004, loss is 3.833077
  77. epoch: 4 step: 5004, loss is 3.2795618
  78. epoch: 5 step: 5004, loss is 3.1978393
  79. ```
  80. ## [Evaluation process](#contents)
  81. ### Usage
  82. You can start training using python or shell scripts. The usage of shell scripts as follows:
  83. - Ascend: sh run_infer.sh Ascend [DATASET_PATH] [CHECKPOINT_PATH]
  84. ### Launch
  85. ```
  86. # infer example
  87. shell:
  88. Ascend: sh run_infer.sh Ascend ~/imagenet/val/ ~/train/Resnet50-30_5004.ckpt
  89. ```
  90. > checkpoint can be produced in training process.
  91. ### Result
  92. Inference result will be stored in the example path, you can find result like the followings in `./eval/infer.log`.
  93. ```
  94. result: {'acc': 0.76576314102564111}
  95. ```
  96. # [Model description](#contents)
  97. ## [Performance](#contents)
  98. ### Training Performance
  99. | Parameters | Resnet50 |
  100. | -------------------------- | ---------------------------------------------------------- |
  101. | Model Version | V1 |
  102. | Resource | Ascend 910, cpu:2.60GHz 56cores, memory:314G |
  103. | uploaded Date | 06/06/2020 |
  104. | MindSpore Version | 0.3.0 |
  105. | Dataset | ImageNet |
  106. | Training Parameters | src/config.py |
  107. | Optimizer | Momentum |
  108. | Loss Function | SoftmaxCrossEntropy |
  109. | outputs | ckpt file |
  110. | Loss | 1.8 |
  111. | Accuracy | |
  112. | Total time | 16h |
  113. | Params (M) | batch_size=32, epoch=30 |
  114. | Checkpoint for Fine tuning | |
  115. | Model for inference | |
  116. #### Evaluation Performance
  117. | Parameters | Resnet50 |
  118. | -------------------------- | ----------------------------- |
  119. | Model Version | V1 |
  120. | Resource | Ascend 910 |
  121. | uploaded Date | 06/06/2020 |
  122. | MindSpore Version | 0.3.0 |
  123. | Dataset | ImageNet, 1.2W |
  124. | batch_size | 130(8P) |
  125. | outputs | probability |
  126. | Accuracy | ACC1[76.57%] ACC5[92.90%] |
  127. | Speed | 5ms/step |
  128. | Total time | 5min |
  129. | Model for inference | |
  130. # [Description of Random Situation](#contents)
  131. In dataset.py, we set the seed inside “create_dataset" function. We also use random seed in train.py.
  132. # [ModelZoo Homepage](#contents)
  133. Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).