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.5 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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, 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 will get the loss value of each step as following:
  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, evaluate LeNet according to network model
  32. ```python
  33. # evaluate 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. Here are some optional parameters:
  38. ```bash
  39. --device_target {Ascend,GPU,CPU}
  40. device where the code will be implemented (default: Ascend)
  41. --data_path DATA_PATH
  42. path where the dataset is saved
  43. --dataset_sink_mode DATASET_SINK_MODE
  44. dataset_sink_mode is False or True
  45. ```
  46. You can run ```python train.py -h``` or ```python eval.py -h``` to get more information.