mindspore/example/lenet_mnist
wukesong 5105e95160 add lenet&alexnet readme in example 2020-04-22 11:08:01 +08:00
..
README.md add lenet&alexnet readme in example 2020-04-22 11:08:01 +08:00
config.py add lenet & alexnet in master branch 2020-03-31 17:14:44 +08:00
dataset.py add lenet & alexnet in master branch 2020-03-31 17:14:44 +08:00
eval.py add lenet & alexnet in master branch 2020-03-31 17:14:44 +08:00
train.py add lenet & alexnet in master branch 2020-03-31 17:14:44 +08:00

README.md

LeNet Example

Description

Training LeNet with MNIST dataset in MindSpore.

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

Requirements

└─MNIST_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 MNIST_Data

You can get loss with each step similar to this:

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, test LeNet according to network model

# test LeNet, after 1 epoch training, the accuracy is up to 96.5%
python eval.py --data_path MNIST_Data --mode test --ckpt_path checkpoint_lenet-1_1875.ckpt

Note

There are some optional arguments:

-h, --help           show this help message and exit
--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.