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

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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](http://10.90.67.50/mindspore/archive/20200506/OpenSource/me_vm_x86/)
  40. - For more information, please check the resources below:
  41. - [MindSpore tutorials](https://www.mindspore.cn/tutorial/zh-CN/master/index.html)
  42. - [MindSpore API](https://www.mindspore.cn/api/zh-CN/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. ```
  85. python train.py --data_path cifar-10-batches-bin --ckpt_path ckpt > log.txt 2>&1 &
  86. # or enter script dir, and run the script
  87. sh run_standalone_train_ascend.sh cifar-10-batches-bin ckpt
  88. ```
  89. After training, the loss value will be achieved as follows:
  90. ```
  91. # grep "loss is " train.log
  92. epoch: 1 step: 1, loss is 2.2791853
  93. ...
  94. epoch: 1 step: 1536, loss is 1.9366643
  95. epoch: 1 step: 1537, loss is 1.6983616
  96. epoch: 1 step: 1538, loss is 1.0221305
  97. ...
  98. ```
  99. The model checkpoint will be saved in the current directory.
  100. ## [Evaluation Process](#contents)
  101. ### Evaluation
  102. Before running the command below, please check the checkpoint path used for evaluation.
  103. ```
  104. python eval.py --data_path cifar-10-verify-bin --ckpt_path ckpt/checkpoint_alexnet-1_1562.ckpt > log.txt 2>&1 &
  105. or enter script dir, and run the script
  106. sh run_standalone_eval_ascend.sh cifar-10-verify-bin ckpt/checkpoint_alexnet-1_1562.ckpt
  107. ```
  108. You can view the results through the file "log.txt". The accuracy of the test dataset will be as follows:
  109. ```
  110. # grep "Accuracy: " log.txt
  111. 'Accuracy': 0.8832
  112. ```
  113. # [Model Description](#contents)
  114. ## [Performance](#contents)
  115. ### Evaluation Performance
  116. | Parameters | AlexNet |
  117. | -------------------------- | ----------------------------------------------------------- |
  118. | Resource | Ascend 910 ;CPU 2.60GHz,56cores;Memory,314G |
  119. | uploaded Date | 06/09/2020 (month/day/year) |
  120. | MindSpore Version | 0.5.0-beta |
  121. | Dataset | CIFAR-10 |
  122. | Training Parameters | epoch=30, steps=1562, batch_size = 32, lr=0.002 |
  123. | Optimizer | Momentum |
  124. | Loss Function | Softmax Cross Entropy |
  125. | outputs | probability |
  126. | Loss | 0.0016 |
  127. | Speed | 21 ms/step |
  128. | Total time | 17 mins |
  129. | Checkpoint for Fine tuning | 445M (.ckpt file) |
  130. | Scripts | https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/alexnet |
  131. # [Description of Random Situation](#contents)
  132. In dataset.py, we set the seed inside ```create_dataset``` function.
  133. # [ModelZoo Homepage](#contents)
  134. Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).