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.5 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
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. Note that you can run the scripts based on the dataset mentioned in original paper or widely used in relevant domain/network architecture. In the following sections, we will introduce how to run the scripts using the related dataset below.
  25. Dataset used: [CIFAR-10](<http://www.cs.toronto.edu/~kriz/cifar.html>)
  26. - Dataset size:175M,60,000 32*32 colorful images in 10 classes
  27. - Train:146M,50,000 images
  28. - Test:29.3M,10,000 images
  29. - Data format:binary files
  30. - Note:Data will be processed in dataset.py
  31. - Download the dataset, the directory structure is as follows:
  32. ```bash
  33. ├─cifar-10-batches-bin
  34. └─cifar-10-verify-bin
  35. ```
  36. ## [Environment Requirements](#contents)
  37. - Hardware(Ascend/GPU)
  38. - Prepare hardware environment with Ascend or GPU processor.
  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/training/en/master/index.html)
  43. - [MindSpore Python API](https://www.mindspore.cn/doc/api_python/en/master/index.html)
  44. ## [Quick Start](#contents)
  45. After installing MindSpore via the official website, you can start training and evaluation as follows:
  46. ```python
  47. # enter script dir, train AlexNet
  48. sh run_standalone_train_ascend.sh [DATA_PATH] [CKPT_SAVE_PATH]
  49. # enter script dir, evaluate AlexNet
  50. sh run_standalone_eval_ascend.sh [DATA_PATH] [CKPT_NAME]
  51. ```
  52. ## [Script Description](#contents)
  53. ### [Script and Sample Code](#contents)
  54. ```bash
  55. ├── cv
  56. ├── alexnet
  57. ├── README.md // descriptions about alexnet
  58. ├── requirements.txt // package needed
  59. ├── scripts
  60. │ ├──run_standalone_train_gpu.sh // train in gpu
  61. │ ├──run_standalone_train_ascend.sh // train in ascend
  62. │ ├──run_standalone_eval_gpu.sh // evaluate in gpu
  63. │ ├──run_standalone_eval_ascend.sh // evaluate in ascend
  64. ├── src
  65. │ ├──dataset.py // creating dataset
  66. │ ├──alexnet.py // alexnet architecture
  67. │ ├──config.py // parameter configuration
  68. ├── train.py // training script
  69. ├── eval.py // evaluation script
  70. ```
  71. ### [Script Parameters](#contents)
  72. ```python
  73. Major parameters in train.py and config.py as follows:
  74. --data_path: The absolute full path to the train and evaluation datasets.
  75. --epoch_size: Total training epochs.
  76. --batch_size: Training batch size.
  77. --image_height: Image height used as input to the model.
  78. --image_width: Image width used as input the model.
  79. --device_target: Device where the code will be implemented. Optional values are "Ascend", "GPU".
  80. --checkpoint_path: The absolute full path to the checkpoint file saved after training.
  81. --data_path: Path where the dataset is saved
  82. ```
  83. ### [Training Process](#contents)
  84. #### Training
  85. - running on Ascend
  86. ```bash
  87. python train.py --data_path cifar-10-batches-bin --ckpt_path ckpt > log 2>&1 &
  88. # or enter script dir, and run the script
  89. sh run_standalone_train_ascend.sh cifar-10-batches-bin ckpt
  90. ```
  91. After training, the loss value will be achieved as follows:
  92. ```bash
  93. # grep "loss is " log
  94. epoch: 1 step: 1, loss is 2.2791853
  95. ...
  96. epoch: 1 step: 1536, loss is 1.9366643
  97. epoch: 1 step: 1537, loss is 1.6983616
  98. epoch: 1 step: 1538, loss is 1.0221305
  99. ...
  100. ```
  101. The model checkpoint will be saved in the current directory.
  102. - running on GPU
  103. ```bash
  104. python train.py --device_target "GPU" --data_path cifar-10-batches-bin --ckpt_path ckpt > log 2>&1 &
  105. # or enter script dir, and run the script
  106. sh run_standalone_train_for_gpu.sh cifar-10-batches-bin ckpt
  107. ```
  108. After training, the loss value will be achieved as follows:
  109. ```bash
  110. # grep "loss is " log
  111. epoch: 1 step: 1, loss is 2.3125906
  112. ...
  113. epoch: 30 step: 1560, loss is 0.6687547
  114. epoch: 30 step: 1561, loss is 0.20055409
  115. epoch: 30 step: 1561, loss is 0.103845775
  116. ```
  117. ### [Evaluation Process](#contents)
  118. #### Evaluation
  119. Before running the command below, please check the checkpoint path used for evaluation.
  120. - running on Ascend
  121. ```bash
  122. python eval.py --data_path cifar-10-verify-bin --ckpt_path ckpt/checkpoint_alexnet-1_1562.ckpt > eval_log.txt 2>&1 &
  123. # or enter script dir, and run the script
  124. sh run_standalone_eval_ascend.sh cifar-10-verify-bin ckpt/checkpoint_alexnet-1_1562.ckpt
  125. ```
  126. You can view the results through the file "eval_log". The accuracy of the test dataset will be as follows:
  127. ```bash
  128. # grep "Accuracy: " eval_log
  129. 'Accuracy': 0.8832
  130. ```
  131. - running on GPU
  132. ```bash
  133. python eval.py --device_target "GPU" --data_path cifar-10-verify-bin --ckpt_path ckpt/checkpoint_alexnet-30_1562.ckpt > eval_log 2>&1 &
  134. # or enter script dir, and run the script
  135. sh run_standalone_eval_for_gpu.sh cifar-10-verify-bin ckpt/checkpoint_alexnet-30_1562.ckpt
  136. ```
  137. You can view the results through the file "eval_log". The accuracy of the test dataset will be as follows:
  138. ```bash
  139. # grep "Accuracy: " eval_log
  140. 'Accuracy': 0.88512
  141. ```
  142. ## [Model Description](#contents)
  143. ### [Performance](#contents)
  144. #### Evaluation Performance
  145. | Parameters | Ascend | GPU |
  146. | -------------------------- | ------------------------------------------------------------| -------------------------------------------------|
  147. | Resource | Ascend 910; CPU 2.60GHz, 192cores; Memory 755G; OS Euler2.8 | NV SMX2 V100-32G |
  148. | uploaded Date | 06/09/2020 (month/day/year) | 17/09/2020 (month/day/year) |
  149. | MindSpore Version | 1.0.0 | 0.7.0-beta |
  150. | Dataset | CIFAR-10 | CIFAR-10 |
  151. | Training Parameters | epoch=30, steps=1562, batch_size = 32, lr=0.002 | epoch=30, steps=1562, batch_size = 32, lr=0.002 |
  152. | Optimizer | Momentum | Momentum |
  153. | Loss Function | Softmax Cross Entropy | Softmax Cross Entropy |
  154. | outputs | probability | probability |
  155. | Loss | 0.08 | 0.01 |
  156. | Speed | 7.3 ms/step | 16.8 ms/step |
  157. | Total time | 6 mins | 14 mins |
  158. | Checkpoint for Fine tuning | 445M (.ckpt file) | 445M (.ckpt file) |
  159. | Scripts | [AlexNet Script](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/alexnet) | [AlexNet Script](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/alexnet) |
  160. ## [Description of Random Situation](#contents)
  161. In dataset.py, we set the seed inside ```create_dataset``` function.
  162. ## [ModelZoo Homepage](#contents)
  163. Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).