mindspore/model_zoo/lenet
mindspore-ci-bot fe1d4ca3bd !2555 checkpoint add model_type
Merge pull request !2555 from chenzhongming/r0.5
2020-06-24 15:18:37 +08:00
..
src modify 2020-06-23 22:14:38 +08:00
README.md add src dir 2020-06-19 20:14:37 +08:00
eval.py checkpoint add model_type 2020-06-24 13:48:36 +08:00
train.py dataset sink is false when run in CPU 2020-06-20 11:28:57 +08:00

README.md

LeNet Example

Description

Training LeNet with dataset in MindSpore.

This is the simple and basic tutorial for constructing a network in MindSpore.

Requirements

  • Install MindSpore.

  • Download the dataset, the directory structure is as follows:

└─Data
    ├─test
    │      t10k-images.idx3-ubyte
    │      t10k-labels.idx1-ubyte
    │
    └─train
           train-images.idx3-ubyte
           train-labels.idx1-ubyte

Running the example

# train LeNet, hyperparameter setting in config.py
python train.py --data_path Data

You will get the loss value of each step as following:

epoch: 1 step: 1, loss is 2.3040335
...
epoch: 1 step: 1739, loss is 0.06952668
epoch: 1 step: 1740, loss is 0.05038793
epoch: 1 step: 1741, loss is 0.05018193
...

Then, evaluate LeNet according to network model

# evaluate LeNet
python eval.py --data_path Data --ckpt_path checkpoint_lenet-1_1875.ckpt

Note

Here are some optional parameters:

--device_target {Ascend,GPU,CPU}
                     device where the code will be implemented (default: Ascend)
--data_path DATA_PATH
                     path where the dataset is saved
--dataset_sink_mode DATASET_SINK_MODE
                     dataset_sink_mode is False or True

You can run python train.py -h or python eval.py -h to get more information.