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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. # NASNet Example
  2. ## Description
  3. This is an example of training NASNet-A-Mobile in MindSpore.
  4. ## Requirements
  5. - Install [Mindspore](http://www.mindspore.cn/install/en).
  6. - Download the dataset.
  7. ## Structure
  8. ```shell
  9. .
  10. └─nasnet
  11. ├─README.md
  12. ├─scripts
  13. ├─run_standalone_train_for_gpu.sh # launch standalone training with gpu platform(1p)
  14. ├─run_distribute_train_for_gpu.sh # launch distributed training with gpu platform(8p)
  15. └─run_eval_for_gpu.sh # launch evaluating with gpu platform
  16. ├─src
  17. ├─config.py # parameter configuration
  18. ├─dataset.py # data preprocessing
  19. ├─loss.py # Customized CrossEntropy loss function
  20. ├─lr_generator.py # learning rate generator
  21. ├─nasnet_a_mobile.py # network definition
  22. ├─eval.py # eval net
  23. ├─export.py # convert checkpoint
  24. └─train.py # train net
  25. ```
  26. ## Parameter Configuration
  27. Parameters for both training and evaluating can be set in config.py
  28. ```
  29. 'random_seed': 1, # fix random seed
  30. 'rank': 0, # local rank of distributed
  31. 'group_size': 1, # world size of distributed
  32. 'work_nums': 8, # number of workers to read the data
  33. 'epoch_size': 250, # total epoch numbers
  34. 'keep_checkpoint_max': 100, # max numbers to keep checkpoints
  35. 'ckpt_path': './checkpoint/', # save checkpoint path
  36. 'is_save_on_master': 1 # save checkpoint on rank0, distributed parameters
  37. 'batch_size': 32, # input batchsize
  38. 'num_classes': 1000, # dataset class numbers
  39. 'label_smooth_factor': 0.1, # label smoothing factor
  40. 'aux_factor': 0.4, # loss factor of aux logit
  41. 'lr_init': 0.04, # initiate learning rate
  42. 'lr_decay_rate': 0.97, # decay rate of learning rate
  43. 'num_epoch_per_decay': 2.4, # decay epoch number
  44. 'weight_decay': 0.00004, # weight decay
  45. 'momentum': 0.9, # momentum
  46. 'opt_eps': 1.0, # epsilon
  47. 'rmsprop_decay': 0.9, # rmsprop decay
  48. 'loss_scale': 1, # loss scale
  49. ```
  50. ## Running the example
  51. ### Train
  52. #### Usage
  53. ```
  54. # distribute training example(8p)
  55. sh run_distribute_train_for_gpu.sh DATA_DIR
  56. # standalone training
  57. sh run_standalone_train_for_gpu.sh DEVICE_ID DATA_DIR
  58. ```
  59. #### Launch
  60. ```bash
  61. # distributed training example(8p) for GPU
  62. sh scripts/run_distribute_train_for_gpu.sh /dataset/train
  63. # standalone training example for GPU
  64. sh scripts/run_standalone_train_for_gpu.sh 0 /dataset/train
  65. ```
  66. #### Result
  67. You can find checkpoint file together with result in log.
  68. ### Evaluation
  69. #### Usage
  70. ```
  71. # Evaluation
  72. sh run_eval_for_gpu.sh DEVICE_ID DATA_DIR PATH_CHECKPOINT
  73. ```
  74. #### Launch
  75. ```bash
  76. # Evaluation with checkpoint
  77. sh scripts/run_eval_for_gpu.sh 0 /dataset/val ./checkpoint/nasnet-a-mobile-rank0-248_10009.ckpt
  78. ```
  79. > checkpoint can be produced in training process.
  80. #### Result
  81. Evaluation result will be stored in the scripts path. Under this, you can find result like the followings in log.