Repository: incubator-singa
Updated Branches:
  refs/heads/dev 7e050c120 -> 95091dcb6


SINGA-225 Documentation for installation and Cifar10 example

Draft documentation for installation and Cifar10 example


Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/722a59e6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/722a59e6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/722a59e6

Branch: refs/heads/dev
Commit: 722a59e6fd94737d2593fa5c61beb768c0a2d6ac
Parents: 7e050c1
Author: kaiping <[email protected]>
Authored: Fri Jul 15 17:30:59 2016 +0800
Committer: kaiping <[email protected]>
Committed: Fri Jul 15 17:30:59 2016 +0800

----------------------------------------------------------------------
 doc/docs/cnn.md          | 151 ++++++++++++++++++++++++++++++++++++++++++
 doc/docs/installation.md |  29 ++++++++
 2 files changed, 180 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/722a59e6/doc/docs/cnn.md
----------------------------------------------------------------------
diff --git a/doc/docs/cnn.md b/doc/docs/cnn.md
new file mode 100755
index 0000000..6566e41
--- /dev/null
+++ b/doc/docs/cnn.md
@@ -0,0 +1,151 @@
+#Quickstart - Cifar10 example
+Convolutional neural network (CNN) is a type of feed-forward artificial neural 
network widely used for image and video classification. In this example, we 
will use a deep CNN model to do image classification for the [CIFAR10 
dataset](http://www.cs.toronto.edu/~kriz/cifar.html).
+
+## Running instructions of CPP version
+To run CNN example in CPP version, we need to compile SINGA first. In 
SINGA_ROOT, execute the following instructions (can also refer to [Installation 
instructions](https://github.com/kaiping/singa_v1.0_doc/blob/master/installation.md))
+
+    # in SINGA_ROOT
+    $ mkdir build
+    $ cd build/
+    # generate Makefile for compilation
+    $ cmake ..
+    # compile SINGA
+    $ make
+
+
+Now download the Cifar10 dataset by running the script download_data.py, 
remember that for downloading CPP version data, we need `bin` as argument,
+
+    # switch to cifar10 directory
+    $ cd ../examples/cifar10
+    # download data for CPP version
+    $ python download_data.py bin
+
+During downloading, you should see the detailed output like
+     
+     Downloading CIFAR10 from 
http://www.cs.toronto.edu/~kriz/cifar-10-binary.tar.gz
+     The tar file does exist. Extracting it now..
+     Finished!
+
+Now you have prepared the data for this Cifar10 example, the final step is to 
execute the `run.sh` script,
+
+    # in SINGA_ROOT/examples/cifar10/
+    $ ./run.sh
+
+You should see the detailed output as follows: first read the data files in 
order, show the statistics of training and testing data, then show the details 
of neural net structure with some parameter information, finally illustrate the 
performance details during training and validation process. The number of 
epochs can be specified in `run.sh` file.
+
+    Start training
+    Reading file cifar-10-batches-bin/data_batch_1.bin
+    Reading file cifar-10-batches-bin/data_batch_2.bin
+    Reading file cifar-10-batches-bin/data_batch_3.bin
+    Reading file cifar-10-batches-bin/data_batch_4.bin
+    Reading file cifar-10-batches-bin/data_batch_5.bin
+    Reading file cifar-10-batches-bin/test_batch.bin
+    Training samples = 50000, Test samples = 10000
+    conv1(32, 32, 32, )
+    pool1(32, 16, 16, )
+    relu1(32, 16, 16, )
+    lrn1(32, 16, 16, )
+    conv2(32, 16, 16, )
+    relu2(32, 16, 16, )
+    pool2(32, 8, 8, )
+    lrn2(32, 8, 8, )
+    conv3(64, 8, 8, )
+    relu3(64, 8, 8, )
+    pool3(64, 4, 4, )
+    flat(1024, )
+    ip(10, )
+    conv1_weight : 8.09309e-05
+    conv1_bias : 0
+    conv2_weight : 0.00797731
+    conv2_bias : 0
+    conv3_weight : 0.00795888
+    conv3_bias : 0
+    ip_weight : 0.00798683
+    ip_bias : 0
+    Messages will be appended to an existed file: train_perf
+    Messages will be appended to an existed file: val_perf
+    Epoch 0, training loss = 1.828369, accuracy = 0.329420, lr = 0.001000
+    Epoch 0, val loss = 1.561823, metric = 0.420600
+    Epoch 1, training loss = 1.465898, accuracy = 0.469940, lr = 0.001000
+    Epoch 1, val loss = 1.361778, metric = 0.513300
+    Epoch 2, training loss = 1.320708, accuracy = 0.529000, lr = 0.001000
+    Epoch 2, val loss = 1.242080, metric = 0.549100
+    Epoch 3, training loss = 1.213776, accuracy = 0.571620, lr = 0.001000
+    Epoch 3, val loss = 1.175346, metric = 0.582000
+
+The training details are stored in `train_perf` file in the same directory and 
the validation details in `val_perf` file. 
+## Running instructions of Python version
+To run CNN example in Python version, we also need to compile SINGA first. In 
SINGA_ROOT, execute the following instructions (can also refer to [Installation 
instructions](https://github.com/kaiping/singa_v1.0_doc/blob/master/installation.md))
+
+    # in SINGA_ROOT
+    $ mkdir build
+    $ cd build/
+    # generate Makefile for compilation
+    $ cmake ..
+    # compile SINGA
+    $ make
+
+
+Now download the Cifar10 dataset by running the script download_data.py, 
remember that for downloading Python version data, we need `py` as argument,
+
+    # switch to cifar10 directory
+    $ cd ../examples/cifar10
+    # download data for Python version
+    $ python download_data.py py
+
+During downloading, you should see the detailed output like
+     
+     Downloading CIFAR10 from 
http://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz
+     The tar file does exist. Extracting it now..
+     Finished!
+
+Then execute the `train.py` script to build the model
+
+    $ python train.py
+
+You should see the output as follows including the details of neural net 
structure with some parameter information, reading data files, and the 
performance details during training and testing process. 
+
+    (32L, 32L, 32L)
+    (32L, 16L, 16L)
+    (32L, 16L, 16L)
+    (32L, 16L, 16L)
+    (32L, 16L, 16L)
+    (32L, 16L, 16L)
+    (32L, 8L, 8L)
+    (32L, 8L, 8L)
+    (64L, 8L, 8L)
+    (64L, 8L, 8L)
+    (64L, 4L, 4L)
+    (1024L,)
+    Start intialization............
+    conv1_weight gaussian 7.938460476e-05
+    conv1_bias constant 0.0
+    conv2_weight gaussian 0.00793507322669
+    conv2_bias constant 0.0
+    conv3_weight gaussian 0.00799657031894
+    conv3_bias constant 0.0
+    dense_weight gaussian 0.00804364029318
+    dense_bias constant 0.0
+    Loading data ..................
+    Loading data file cifar-10-batches-py/data_batch_1
+    Loading data file cifar-10-batches-py/data_batch_2
+    Loading data file cifar-10-batches-py/data_batch_3
+    Loading data file cifar-10-batches-py/data_batch_4
+    Loading data file cifar-10-batches-py/data_batch_5
+    Loading data file cifar-10-batches-py/test_batch
+    Epoch 0
+    training loss = 1.881866, training accuracy = 0.306360 accuracy = 0.420000
+    test loss = 1.602577, test accuracy = 0.412200
+    Epoch 1
+    training loss = 1.536011, training accuracy = 0.441940 accuracy = 0.500000
+    test loss = 1.378170, test accuracy = 0.507600
+    Epoch 2
+    training loss = 1.333137, training accuracy = 0.519960 accuracy = 0.520000
+    test loss = 1.272205, test accuracy = 0.540600
+    Epoch 3
+    training loss = 1.185212, training accuracy = 0.574120 accuracy = 0.540000
+    test loss = 1.211573, test accuracy = 0.567600
+
+This script will call `alexnet.py` file to build the alexnet model. After the 
training is finished, SINGA will save the model parameters into a checkpoint 
file `model.bin` in the same directory. Then we can use this `model.bin` file 
for prediction.
+
+    $ python predict.py
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/722a59e6/doc/docs/installation.md
----------------------------------------------------------------------
diff --git a/doc/docs/installation.md b/doc/docs/installation.md
new file mode 100755
index 0000000..6d80774
--- /dev/null
+++ b/doc/docs/installation.md
@@ -0,0 +1,29 @@
+#Building SINGA from source
+To install SINGA, please clone the newest code from 
[Github](https://github.com/apache/incubator-singa) and execute the following 
commands,
+
+    
+    $ git clone https://github.com/apache/incubator-singa.git
+    $ cd incubator-singa/
+    # switch to dev branch
+    $ git checkout dev
+  
+A SINGA uses CNMem as a submodule in lib/, execute the following commands to 
initialize and update the submodules for SINGA, 
+
+    $ git submodule init
+    $ git submodule update
+
+Then in SINGA_ROOT, execute the following commands for compiling SINGA,
+
+    $ mkdir build
+    $ cd build/
+    # generate Makefile for compilation
+    $ cmake ..
+    # compile SINGA
+    $ make
+
+After compiling SINGA, in order to test all components of SINGA, please 
execute the following commands,
+    
+    $ cd bin/
+    $ ./test_singa
+
+You can see all the testing cases with testing results. If SINGA has passes 
all tests, then you have successfully installed SINGA. Please proceed to enjoy 
SINGA!
\ No newline at end of file

Reply via email to