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 6.4 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
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. # Contents
  2. - [NASNet Description](#nasnet-description)
  3. - [Model Architecture](#model-architecture)
  4. - [Dataset](#dataset)
  5. - [Environment Requirements](#environment-requirements)
  6. - [Quick Start](#quick-start)
  7. - [Script Description](#script-description)
  8. - [Script and Sample Code](#script-and-sample-code)
  9. - [Script Parameters](#script-parameters)
  10. - [Training Process](#training-process)
  11. - [Evaluation Process](#evaluation-process)
  12. - [Model Description](#model-description)
  13. - [Performance](#performance)
  14. - [Training Performance](#evaluation-performance)
  15. - [Inference Performance](#evaluation-performance)
  16. - [ModelZoo Homepage](#modelzoo-homepage)
  17. # [NASNet Description](#contents)
  18. [Paper](https://arxiv.org/abs/1707.07012): Barret Zoph, Vijay Vasudevan, Jonathon Shlens, Quoc V. Le. Learning Transferable Architectures for Scalable Image Recognition. 2017.
  19. # [Model architecture](#contents)
  20. The overall network architecture of NASNet is show below:
  21. [Link](https://arxiv.org/abs/1707.07012)
  22. # [Dataset](#contents)
  23. Dataset used: [imagenet](http://www.image-net.org/)
  24. - Dataset size: ~125G, 1.2W colorful images in 1000 classes
  25. - Train: 120G, 1.2W images
  26. - Test: 5G, 50000 images
  27. - Data format: RGB images.
  28. - Note: Data will be processed in src/dataset.py
  29. # [Environment Requirements](#contents)
  30. - Hardware GPU
  31. - Prepare hardware environment with GPU processor.
  32. - Framework
  33. - [MindSpore](https://www.mindspore.cn/install/en)
  34. - For more information, please check the resources below:
  35. - [MindSpore Tutorials](https://www.mindspore.cn/tutorial/training/en/master/index.html)
  36. - [MindSpore Python API](https://www.mindspore.cn/doc/api_python/en/master/index.html)
  37. # [Script description](#contents)
  38. ## [Script and sample code](#contents)
  39. ```python
  40. .
  41. └─nasnet
  42. ├─README.md
  43. ├─scripts
  44. ├─run_standalone_train_for_gpu.sh # launch standalone training with gpu platform(1p)
  45. ├─run_distribute_train_for_gpu.sh # launch distributed training with gpu platform(8p)
  46. └─run_eval_for_gpu.sh # launch evaluating with gpu platform
  47. ├─src
  48. ├─config.py # parameter configuration
  49. ├─dataset.py # data preprocessing
  50. ├─loss.py # Customized CrossEntropy loss function
  51. ├─lr_generator.py # learning rate generator
  52. ├─nasnet_a_mobile.py # network definition
  53. ├─eval.py # eval net
  54. ├─export.py # convert checkpoint
  55. └─train.py # train net
  56. ```
  57. ## [Script Parameters](#contents)
  58. Parameters for both training and evaluating can be set in config.py.
  59. ```python
  60. 'random_seed': 1, # fix random seed
  61. 'rank': 0, # local rank of distributed
  62. 'group_size': 1, # world size of distributed
  63. 'work_nums': 8, # number of workers to read the data
  64. 'epoch_size': 500, # total epoch numbers
  65. 'keep_checkpoint_max': 100, # max numbers to keep checkpoints
  66. 'ckpt_path': './checkpoint/', # save checkpoint path
  67. 'is_save_on_master': 1 # save checkpoint on rank0, distributed parameters
  68. 'batch_size': 32, # input batchsize
  69. 'num_classes': 1000, # dataset class numbers
  70. 'label_smooth_factor': 0.1, # label smoothing factor
  71. 'aux_factor': 0.4, # loss factor of aux logit
  72. 'lr_init': 0.04, # initiate learning rate
  73. 'lr_decay_rate': 0.97, # decay rate of learning rate
  74. 'num_epoch_per_decay': 2.4, # decay epoch number
  75. 'weight_decay': 0.00004, # weight decay
  76. 'momentum': 0.9, # momentum
  77. 'opt_eps': 1.0, # epsilon
  78. 'rmsprop_decay': 0.9, # rmsprop decay
  79. 'loss_scale': 1, # loss scale
  80. ```
  81. ## [Training Process](#contents)
  82. ### Usage
  83. ```bash
  84. GPU:
  85. # distribute training example(8p)
  86. sh run_distribute_train_for_gpu.sh DATA_DIR
  87. # standalone training
  88. sh run_standalone_train_for_gpu.sh DEVICE_ID DATA_DIR
  89. ```
  90. ### Launch
  91. ```bash
  92. # distributed training example(8p) for GPU
  93. sh scripts/run_distribute_train_for_gpu.sh /dataset/train
  94. # standalone training example for GPU
  95. sh scripts/run_standalone_train_for_gpu.sh 0 /dataset/train
  96. ```
  97. You can find checkpoint file together with result in log.
  98. ## [Evaluation Process](#contents)
  99. ### Usage
  100. ```bash
  101. # Evaluation
  102. sh run_eval_for_gpu.sh DEVICE_ID DATA_DIR PATH_CHECKPOINT
  103. ```
  104. ### Launch
  105. ```bash
  106. # Evaluation with checkpoint
  107. sh scripts/run_eval_for_gpu.sh 0 /dataset/val ./checkpoint/nasnet-a-mobile-rank0-248_10009.ckpt
  108. ```
  109. ### Result
  110. Evaluation result will be stored in the scripts path. Under this, you can find result like the followings in log.
  111. acc=73.5%(TOP1)
  112. # [Model description](#contents)
  113. ## [Performance](#contents)
  114. ### Training Performance
  115. | Parameters | NASNet |
  116. | -------------------------- | ------------------------- |
  117. | Resource | NV SMX2 V100-32G |
  118. | uploaded Date | 09/24/2020 |
  119. | MindSpore Version | 1.0.0 |
  120. | Dataset | ImageNet |
  121. | Training Parameters | src/config.py |
  122. | Optimizer | Momentum |
  123. | Loss Function | SoftmaxCrossEntropyWithLogits |
  124. | Loss | 1.8965 |
  125. | Total time | 144 h 8ps |
  126. | Checkpoint for Fine tuning | 89 M(.ckpt file) |
  127. ### Inference Performance
  128. | Parameters | |
  129. | -------------------------- | ------------------------- |
  130. | Resource | NV SMX2 V100-32G |
  131. | uploaded Date | 09/24/2020 |
  132. | MindSpore Version | 1.0.0 |
  133. | Dataset | ImageNet, 1.2W |
  134. | batch_size | 32 |
  135. | outputs | probability |
  136. | Accuracy | acc=73.5%(TOP1) |
  137. # [ModelZoo Homepage](#contents)
  138. Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).