MnistExamples.rst 4.1 KB
Newer Older
1
2
.. role:: raw-html(raw)
   :format: html
Yan Ni's avatar
Yan Ni committed
3
4


5
6
MNIST examples
==============
Yan Ni's avatar
Yan Ni committed
7

8
9
10
CNN MNIST classifier for deep learning is similar to ``hello world`` for programming languages. Thus, we use MNIST as example to introduce different features of NNI. The examples are listed below:


11
* `MNIST with NNI API (PyTorch) <#mnist-pytorch>`__
12
* `MNIST with NNI API (TensorFlow v2.x) <#mnist-tfv2>`__
13
* `MNIST with NNI API (TensorFlow v1.x) <#mnist-tfv1>`__
14
15
16
17
18
19
20
21
* `MNIST with NNI annotation <#mnist-annotation>`__
* `MNIST in keras <#mnist-keras>`__
* `MNIST -- tuning with batch tuner <#mnist-batch>`__
* `MNIST -- tuning with hyperband <#mnist-hyperband>`__
* `MNIST -- tuning within a nested search space <#mnist-nested>`__
* `distributed MNIST (tensorflow) using kubeflow <#mnist-kubeflow-tf>`__
* `distributed MNIST (pytorch) using kubeflow <#mnist-kubeflow-pytorch>`__

22
23
:raw-html:`<a name="mnist-pytorch"></a>`
**MNIST with NNI API (PyTorch)**
Yan Ni's avatar
Yan Ni committed
24

25
26
27
28
This is a simple network which has two convolutional layers, two pooling layers and a fully connected layer.
We tune hyperparameters, such as dropout rate, convolution size, hidden size, etc.
It can be tuned with most NNI built-in tuners, such as TPE, SMAC, Random.
We also provide an exmaple YAML file which enables assessor.
Yan Ni's avatar
Yan Ni committed
29

30
code directory: :githublink:`mnist-pytorch/ <examples/trials/mnist-pytorch/>`
31

32
:raw-html:`<a name="mnist-tfv2"></a>`
33
34
**MNIST with NNI API (TensorFlow v2.x)**

35
Same network to the example above, but written in TensorFlow.
36

37
code directory: :githublink:`mnist-tfv2/ <examples/trials/mnist-tfv2/>`
Yan Ni's avatar
Yan Ni committed
38

39
40
41
42
43
44
45
:raw-html:`<a name="mnist-tfv1"></a>`
**MNIST with NNI API (TensorFlow v1.x)**

Same network to the example above, but written in TensorFlow v1.x API.

code directory: :githublink:`mnist-tfv1/ <examples/trials/mnist-tfv1/>`

46
:raw-html:`<a name="mnist-annotation"></a>`
Yan Ni's avatar
Yan Ni committed
47
48
49
50
**MNIST with NNI annotation**

This example is similar to the example above, the only difference is that this example uses NNI annotation to specify search space and report results, while the example above uses NNI apis to receive configuration and report results.

51
code directory: :githublink:`mnist-annotation/ <examples/trials/mnist-annotation/>`
Yan Ni's avatar
Yan Ni committed
52

53
:raw-html:`<a name="mnist-batch"></a>`
Yan Ni's avatar
Yan Ni committed
54
55
56
57
**MNIST -- tuning with batch tuner**

This example is to show how to use batch tuner. Users simply list all the configurations they want to try in the search space file. NNI will try all of them.

58
code directory: :githublink:`mnist-batch-tune-keras/ <examples/trials/mnist-batch-tune-keras/>`
Yan Ni's avatar
Yan Ni committed
59

60
:raw-html:`<a name="mnist-hyperband"></a>`
Yan Ni's avatar
Yan Ni committed
61
62
**MNIST -- tuning with hyperband**

63
This example is to show how to use hyperband to tune the model. There is one more key ``STEPS`` in the received configuration for trials to control how long it can run (e.g., number of iterations).
Yan Ni's avatar
Yan Ni committed
64

65
66
67
.. cannot find :githublink:`mnist-hyperband/ <examples/trials/mnist-hyperband/>`

code directory: :githublink:`mnist-hyperband/ <examples/trials/mnist-hyperband/>`
Yan Ni's avatar
Yan Ni committed
68

69
:raw-html:`<a name="mnist-nested"></a>`
Yan Ni's avatar
Yan Ni committed
70
71
72
73
**MNIST -- tuning within a nested search space**

This example is to show that NNI also support nested search space. The search space file is an example of how to define nested search space.

74
code directory: :githublink:`mnist-nested-search-space/ <examples/trials/mnist-nested-search-space/>`
Yan Ni's avatar
Yan Ni committed
75

76
:raw-html:`<a name="mnist-kubeflow-tf"></a>`
Yan Ni's avatar
Yan Ni committed
77
78
79
80
**distributed MNIST (tensorflow) using kubeflow**

This example is to show how to run distributed training on kubeflow through NNI. Users can simply provide distributed training code and a configure file which specifies the kubeflow mode. For example, what is the command to run ps and what is the command to run worker, and how many resources they consume. This example is implemented in tensorflow, thus, uses kubeflow tensorflow operator.

81
code directory: :githublink:`mnist-distributed/ <examples/trials/mnist-distributed/>`
Yan Ni's avatar
Yan Ni committed
82

83
:raw-html:`<a name="mnist-kubeflow-pytorch"></a>`
Yan Ni's avatar
Yan Ni committed
84
85
86
87
**distributed MNIST (pytorch) using kubeflow**

Similar to the previous example, the difference is that this example is implemented in pytorch, thus, it uses kubeflow pytorch operator.

88
code directory: :githublink:`mnist-distributed-pytorch/ <examples/trials/mnist-distributed-pytorch/>`