Browse Source

!544 add lenet& alexnet readme in example

Merge pull request !544 from wukesong/wks-add-readme
tags/v0.2.0-alpha
mindspore-ci-bot Gitee 6 years ago
parent
commit
9edc69affe
2 changed files with 121 additions and 0 deletions
  1. +58
    -0
      example/alexnet_cifar10/README.md
  2. +63
    -0
      example/lenet_mnist/README.md

+ 58
- 0
example/alexnet_cifar10/README.md View File

@@ -0,0 +1,58 @@
# AlexNet Example

## Description

Training AlexNet with CIFAR-10 dataset in MindSpore.

This is the simple tutorial for training AlexNet in MindSpore.

## Requirements

- Install [MindSpore](https://www.mindspore.cn/install/en).

- Download the CIFAR-10 dataset at <http://www.cs.toronto.edu/~kriz/cifar-10-binary.tar.gz>. The directory structure is as follows:

```
├─cifar-10-batches-bin
└─cifar-10-verify-bin
```

## Running the example

```python
# train AlexNet, hyperparameter setting in config.py
python train.py --data_path cifar-10-batches-bin
```

You can get loss with each step similar to this:

```bash
epoch: 1 step: 1, loss is 2.2791853
...
epoch: 1 step: 1536, loss is 1.9366643
epoch: 1 step: 1537, loss is 1.6983616
epoch: 1 step: 1538, loss is 1.0221305
...
```

Then, test AlexNet according to network model
```python
# test AlexNet, 1 epoch training accuracy is up to 51.1%; 10 epoch training accuracy is up to 81.2%
python eval.py --data_path cifar-10-verify-bin --mode test --ckpt_path checkpoint_alexnet-1_1562.ckpt
```

## Note
There are some optional arguments:

```bash
-h, --help show this help message and exit
--device_target {Ascend,GPU}
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.

+ 63
- 0
example/lenet_mnist/README.md View File

@@ -0,0 +1,63 @@
# LeNet Example

## Description

Training LeNet with MNIST dataset in MindSpore.

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

## Requirements

- Install [MindSpore](https://www.mindspore.cn/install/en).

- Download the MNIST dataset at <http://yann.lecun.com/exdb/mnist/>. The directory structure is as follows:

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

## Running the example

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

You can get loss with each step similar to this:

```bash
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
```python
# 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:

```bash
-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.

Loading…
Cancel
Save