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 9.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
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
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. # Contents
  2. - [AlexNet Description](#alexnet-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. - [Training](#training)
  12. - [Evaluation Process](#evaluation-process)
  13. - [Evaluation](#evaluation)
  14. - [Model Description](#model-description)
  15. - [Performance](#performance)
  16. - [Evaluation Performance](#evaluation-performance)
  17. - [ModelZoo Homepage](#modelzoo-homepage)
  18. # [AlexNet Description](#contents)
  19. AlexNet was proposed in 2012, one of the most influential neural networks. It got big success in ImageNet Dataset recognition than other models.
  20. [Paper](http://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf): Krizhevsky A, Sutskever I, Hinton G E. ImageNet Classification with Deep ConvolutionalNeural Networks. *Advances In Neural Information Processing Systems*. 2012.
  21. # [Model Architecture](#contents)
  22. AlexNet composition consists of 5 convolutional layers and 3 fully connected layers. Multiple convolutional kernels can extract interesting features in images and get more accurate classification.
  23. # [Dataset](#contents)
  24. Dataset used: [CIFAR-10](<http://www.cs.toronto.edu/~kriz/cifar.html>)
  25. - Dataset size:175M,60,000 32*32 colorful images in 10 classes
  26. - Train:146M,50,000 images
  27. - Test:29.3M,10,000 images
  28. - Data format:binary files
  29. - Note:Data will be processed in dataset.py
  30. - Download the dataset, the directory structure is as follows:
  31. ```
  32. ├─cifar-10-batches-bin
  33. └─cifar-10-verify-bin
  34. ```
  35. # [Environment Requirements](#contents)
  36. - Hardware(Ascend/GPU)
  37. - Prepare hardware environment with Ascend or GPU processor.
  38. - Framework
  39. - [MindSpore](https://www.mindspore.cn/install/en)
  40. - For more information, please check the resources below:
  41. - [MindSpore Tutorials](https://www.mindspore.cn/tutorial/training/en/master/index.html)
  42. - [MindSpore Python API](https://www.mindspore.cn/doc/api_python/en/master/index.html)
  43. # [Quick Start](#contents)
  44. After installing MindSpore via the official website, you can start training and evaluation as follows:
  45. ```python
  46. # enter script dir, train AlexNet
  47. sh run_standalone_train_ascend.sh [DATA_PATH] [CKPT_SAVE_PATH]
  48. # enter script dir, evaluate AlexNet
  49. sh run_standalone_eval_ascend.sh [DATA_PATH] [CKPT_NAME]
  50. ```
  51. # [Script Description](#contents)
  52. ## [Script and Sample Code](#contents)
  53. ```
  54. ├── cv
  55. ├── alexnet
  56. ├── README.md // descriptions about alexnet
  57. ├── requirements.txt // package needed
  58. ├── scripts
  59. │ ├──run_standalone_train_gpu.sh // train in gpu
  60. │ ├──run_standalone_train_ascend.sh // train in ascend
  61. │ ├──run_standalone_eval_gpu.sh // evaluate in gpu
  62. │ ├──run_standalone_eval_ascend.sh // evaluate in ascend
  63. ├── src
  64. │ ├──dataset.py // creating dataset
  65. │ ├──alexnet.py // alexnet architecture
  66. │ ├──config.py // parameter configuration
  67. ├── train.py // training script
  68. ├── eval.py // evaluation script
  69. ```
  70. ## [Script Parameters](#contents)
  71. ```python
  72. Major parameters in train.py and config.py as follows:
  73. --data_path: The absolute full path to the train and evaluation datasets.
  74. --epoch_size: Total training epochs.
  75. --batch_size: Training batch size.
  76. --image_height: Image height used as input to the model.
  77. --image_width: Image width used as input the model.
  78. --device_target: Device where the code will be implemented. Optional values are "Ascend", "GPU".
  79. --checkpoint_path: The absolute full path to the checkpoint file saved after training.
  80. --data_path: Path where the dataset is saved
  81. ```
  82. ## [Training Process](#contents)
  83. ### Training
  84. - running on Ascend
  85. ```
  86. python train.py --data_path cifar-10-batches-bin --ckpt_path ckpt > log.txt 2>&1 &
  87. # or enter script dir, and run the script
  88. sh run_standalone_train_ascend.sh cifar-10-batches-bin ckpt
  89. ```
  90. After training, the loss value will be achieved as follows:
  91. ```
  92. # grep "loss is " train.log
  93. epoch: 1 step: 1, loss is 2.2791853
  94. ...
  95. epoch: 1 step: 1536, loss is 1.9366643
  96. epoch: 1 step: 1537, loss is 1.6983616
  97. epoch: 1 step: 1538, loss is 1.0221305
  98. ...
  99. ```
  100. The model checkpoint will be saved in the current directory.
  101. - running on GPU
  102. ```
  103. python train.py --device_target "GPU" --data_path cifar-10-batches-bin --ckpt_path ckpt > log.txt 2>&1 &
  104. # or enter script dir, and run the script
  105. sh run_standalone_train_for_gpu.sh cifar-10-batches-bin ckpt
  106. ```
  107. After training, the loss value will be achieved as follows:
  108. ```
  109. # grep "loss is " train.log
  110. epoch: 1 step: 1, loss is 2.3125906
  111. ...
  112. epoch: 30 step: 1560, loss is 0.6687547
  113. epoch: 30 step: 1561, loss is 0.20055409
  114. epoch: 30 step: 1561, loss is 0.103845775
  115. ```
  116. ## [Evaluation Process](#contents)
  117. ### Evaluation
  118. Before running the command below, please check the checkpoint path used for evaluation.
  119. - running on Ascend
  120. ```
  121. python eval.py --data_path cifar-10-verify-bin --ckpt_path ckpt/checkpoint_alexnet-1_1562.ckpt > log.txt 2>&1 &
  122. # or enter script dir, and run the script
  123. sh run_standalone_eval_ascend.sh cifar-10-verify-bin ckpt/checkpoint_alexnet-1_1562.ckpt
  124. ```
  125. You can view the results through the file "log.txt". The accuracy of the test dataset will be as follows:
  126. ```
  127. # grep "Accuracy: " log.txt
  128. 'Accuracy': 0.8832
  129. ```
  130. - running on GPU
  131. ```
  132. python eval.py --device_target "GPU" --data_path cifar-10-verify-bin --ckpt_path ckpt/checkpoint_alexnet-30_1562.ckpt > log.txt 2>&1 &
  133. # or enter script dir, and run the script
  134. sh run_standalone_eval_for_gpu.sh cifar-10-verify-bin ckpt/checkpoint_alexnet-30_1562.ckpt
  135. ```
  136. You can view the results through the file "log.txt". The accuracy of the test dataset will be as follows:
  137. ```
  138. # grep "Accuracy: " log.txt
  139. 'Accuracy': 0.88512
  140. ```
  141. # [Model Description](#contents)
  142. ## [Performance](#contents)
  143. ### Evaluation Performance
  144. | Parameters | Ascend | GPU |
  145. | -------------------------- | ------------------------------------------------------------| -------------------------------------------------|
  146. | Resource | Ascend 910; CPU 2.60GHz, 192cores; Memory, 755G | NV SMX2 V100-32G |
  147. | uploaded Date | 06/09/2020 (month/day/year) | 17/09/2020 (month/day/year) |
  148. | MindSpore Version | 0.5.0-beta | 0.7.0-beta |
  149. | Dataset | CIFAR-10 | CIFAR-10 |
  150. | Training Parameters | epoch=30, steps=1562, batch_size = 32, lr=0.002 | epoch=30, steps=1562, batch_size = 32, lr=0.002 |
  151. | Optimizer | Momentum | Momentum |
  152. | Loss Function | Softmax Cross Entropy | Softmax Cross Entropy |
  153. | outputs | probability | probability |
  154. | Loss | 0.0016 | 0.01 |
  155. | Speed | 21 ms/step | 16.8 ms/step |
  156. | Total time | 17 mins | 14 mins |
  157. | Checkpoint for Fine tuning | 445M (.ckpt file) | 445M (.ckpt file) |
  158. | Scripts | https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/alexnet | https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/alexnet |
  159. # [Description of Random Situation](#contents)
  160. In dataset.py, we set the seed inside ```create_dataset``` function.
  161. # [ModelZoo Homepage](#contents)
  162. Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).