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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # LeNet Example
  2. ## Description
  3. Training LeNet with MNIST dataset in MindSpore.
  4. This is the simple and basic tutorial for constructing a network in MindSpore.
  5. ## Requirements
  6. - Install [MindSpore](https://www.mindspore.cn/install/en).
  7. - Download the MNIST dataset at <http://yann.lecun.com/exdb/mnist/>. The directory structure is as follows:
  8. ```
  9. └─MNIST_Data
  10. ├─test
  11. │ t10k-images.idx3-ubyte
  12. │ t10k-labels.idx1-ubyte
  13. └─train
  14. train-images.idx3-ubyte
  15. train-labels.idx1-ubyte
  16. ```
  17. ## Running the example
  18. ```python
  19. # train LeNet, hyperparameter setting in config.py
  20. python train.py --data_path MNIST_Data
  21. ```
  22. You can get loss with each step similar to this:
  23. ```bash
  24. epoch: 1 step: 1, loss is 2.3040335
  25. ...
  26. epoch: 1 step: 1739, loss is 0.06952668
  27. epoch: 1 step: 1740, loss is 0.05038793
  28. epoch: 1 step: 1741, loss is 0.05018193
  29. ...
  30. ```
  31. Then, test LeNet according to network model
  32. ```python
  33. # test LeNet, after 1 epoch training, the accuracy is up to 96.5%
  34. python eval.py --data_path MNIST_Data --mode test --ckpt_path checkpoint_lenet-1_1875.ckpt
  35. ```
  36. ## Note
  37. There are some optional arguments:
  38. ```bash
  39. -h, --help show this help message and exit
  40. --device_target {Ascend,GPU,CPU}
  41. device where the code will be implemented (default: Ascend)
  42. --data_path DATA_PATH
  43. path where the dataset is saved
  44. --dataset_sink_mode DATASET_SINK_MODE
  45. dataset_sink_mode is False or True
  46. ```
  47. You can run ```python train.py -h``` or ```python eval.py -h``` to get more information.