Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 47ABA200C40 for ; Mon, 13 Feb 2017 06:13:29 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 464FB160B6B; Mon, 13 Feb 2017 05:13:29 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 544A8160B76 for ; Mon, 13 Feb 2017 06:13:26 +0100 (CET) Received: (qmail 32853 invoked by uid 500); 13 Feb 2017 05:13:25 -0000 Mailing-List: contact commits-help@singa.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@singa.incubator.apache.org Delivered-To: mailing list commits@singa.incubator.apache.org Received: (qmail 32734 invoked by uid 99); 13 Feb 2017 05:13:25 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Feb 2017 05:13:25 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 121193A47EE for ; Mon, 13 Feb 2017 05:13:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1782721 [11/24] - in /incubator/singa/site/trunk/v1.1.0: ./ _sources/ _sources/community/ _sources/develop/ _sources/docs/ _sources/docs/examples/ _sources/docs/examples/caffe/ _sources/docs/examples/char-rnn/ _sources/docs/examples/cifar1... Date: Mon, 13 Feb 2017 05:13:22 -0000 To: commits@singa.apache.org From: wangwei@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170213051324.121193A47EE@svn01-us-west.apache.org> archived-at: Mon, 13 Feb 2017 05:13:29 -0000 Added: incubator/singa/site/trunk/v1.1.0/docs.html URL: http://svn.apache.org/viewvc/incubator/singa/site/trunk/v1.1.0/docs.html?rev=1782721&view=auto ============================================================================== --- incubator/singa/site/trunk/v1.1.0/docs.html (added) +++ incubator/singa/site/trunk/v1.1.0/docs.html Mon Feb 13 05:13:19 2017 @@ -0,0 +1,341 @@ + + + + + + + + + + + + Documentation — incubator-singa 1.1.0 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+ + + + + + +
+
    +
  • Docs »
  • + +
  • Documentation
  • +
  • + + + +
  • +
+
+
+ +
+ + +
+ +
+

+ © Copyright 2017 The Apache Software Foundation. All rights reserved. Apache Singa, Apache, the Apache feather logo, and the Apache Singa project logos are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.. + +

+
+ Built with Sphinx using a theme provided by Read the Docs. + +
+ +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + incubator-singa + v: latest + + +
+
+
Languages
+
English
+
中文
+
+
+
Versions
+
0.3
+
1.1
+
+ +
+ +
+ + + Fork me on GitHub + + + + + + + \ No newline at end of file Added: incubator/singa/site/trunk/v1.1.0/docs/cnn.html URL: http://svn.apache.org/viewvc/incubator/singa/site/trunk/v1.1.0/docs/cnn.html?rev=1782721&view=auto ============================================================================== --- incubator/singa/site/trunk/v1.1.0/docs/cnn.html (added) +++ incubator/singa/site/trunk/v1.1.0/docs/cnn.html Mon Feb 13 05:13:19 2017 @@ -0,0 +1,379 @@ + + + + + + + + + + + + Running instructions for CPP version — incubator-singa 1.1.0 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+ + + + + + +
+
    +
  • Docs »
  • + +
  • Running instructions for CPP version
  • +
  • + + + +
  • +
+
+
+
+
+ +

#Quickstart - Cifar10 example +Convolution neural network (CNN) is a type of feed-forward artificial neural network widely used for image classification. In this example, we will use a deep CNN model to do image classification for the CIFAR10 dataset.

+
+

Running instructions for CPP version¶

+

Please refer to Installation page for how to install SINGA. Currently, we CNN requires CUDNN, hence both CUDA and CUDNN should be installed and SINGA should be compiled with CUDA and CUDNN.

+

The Cifar10 dataset could be downloaded by running

+
# switch to cifar10 directory
+$ cd ../examples/cifar10
+# download data for CPP version
+$ python download_data.py bin
+
+
+

‘bin’ is for downloading binary version of Cifar10 data.

+

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 for Python version¶

+

To run CNN example in Python version, we need to compile SINGA with Python binding,

+
$ mkdir build && cd build
+$ cmake -DUSE_PYTHON=ON ..
+$ make
+
+
+

Now download the Cifar10 dataset,

+
# 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
+
+
+
+ + +
+
+
+ + +
+ +
+

+ © Copyright 2017 The Apache Software Foundation. All rights reserved. Apache Singa, Apache, the Apache feather logo, and the Apache Singa project logos are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.. + +

+
+ Built with Sphinx using a theme provided by Read the Docs. + +
+ +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + incubator-singa + v: latest + + +
+
+
Languages
+
English
+
中文
+
+
+
Versions
+
0.3
+
1.1
+
+ +
+ +
+ + + Fork me on GitHub + + + + + + + \ No newline at end of file Added: incubator/singa/site/trunk/v1.1.0/docs/converter.html URL: http://svn.apache.org/viewvc/incubator/singa/site/trunk/v1.1.0/docs/converter.html?rev=1782721&view=auto ============================================================================== --- incubator/singa/site/trunk/v1.1.0/docs/converter.html (added) +++ incubator/singa/site/trunk/v1.1.0/docs/converter.html Mon Feb 13 05:13:19 2017 @@ -0,0 +1,273 @@ + + + + + + + + + + + + Caffe Converter — incubator-singa 1.1.0 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+ + + + + + +
+ +
+
+
+
+ +
+

Caffe Converter¶

+
+ + +
+
+
+ + + + +
+ +
+

+ © Copyright 2017 The Apache Software Foundation. All rights reserved. Apache Singa, Apache, the Apache feather logo, and the Apache Singa project logos are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.. + +

+
+ Built with Sphinx using a theme provided by Read the Docs. + +
+ +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + incubator-singa + v: latest + + +
+
+
Languages
+
English
+
中文
+
+
+
Versions
+
0.3
+
1.1
+
+ +
+ +
+ + + Fork me on GitHub + + + + + + + \ No newline at end of file Added: incubator/singa/site/trunk/v1.1.0/docs/data.html URL: http://svn.apache.org/viewvc/incubator/singa/site/trunk/v1.1.0/docs/data.html?rev=1782721&view=auto ============================================================================== --- incubator/singa/site/trunk/v1.1.0/docs/data.html (added) +++ incubator/singa/site/trunk/v1.1.0/docs/data.html Mon Feb 13 05:13:19 2017 @@ -0,0 +1,329 @@ + + + + + + + + + + + + Data — incubator-singa 1.1.0 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+ + + + + + +
+ +
+
+
+
+ +
+

Data¶

+

This module includes classes for loading and prefetching data batches.

+

Example usage:

+
import image_tool
+from PIL import Image
+
+tool = image_tool.ImageTool()
+
+def image_transform(img_path):
+    global tool
+    return tool.load(img_path).resize_by_range(
+        (112, 128)).random_crop(
+        (96, 96)).flip().get()
+
+data = ImageBatchIter('train.txt', 3,
+                      image_transform, shuffle=True, delimiter=',',
+                      image_folder='images/',
+                      capacity=10)
+data.start()
+# imgs is a numpy array for a batch of images,
+# shape: batch_size, 3 (RGB), height, width
+imgs, labels = data.next()
+
+# convert numpy array back into images
+for idx in range(imgs.shape[0]):
+    img = Image.fromarray(imgs[idx].astype(np.uint8).transpose(1, 2, 0),
+                          'RGB')
+    img.save('img%d.png' % idx)
+data.end()
+
+
+
+
+class singa.data.ImageBatchIter(img_list_file, batch_size, image_transform, shuffle=True, delimiter=' ', image_folder=None, capacity=10)¶
+

Utility for iterating over an image dataset to get mini-batches.

+ +++ + + + +
Parameters:
    +
  • img_list_file (str) – name of the file containing image meta data; each +line consists of image_path_suffix delimiter label
  • +
  • batch_size (int) – num of samples in one mini-batch
  • +
  • image_transform – a function for image augmentation; it accepts the full +image path and outputs a list of augmented images.
  • +
  • shuffle (boolean) – True for shuffling images in the list
  • +
  • delimiter (char) – delimiter between image_path_suffix and label, e.g., +space or comma
  • +
  • image_folder (boolean) – prefix of the image path
  • +
  • capacity (int) – the max num of mini-batches in the internal queue.
  • +
+
+
+ +
+ + +
+
+
+ + + + +
+ +
+

+ © Copyright 2017 The Apache Software Foundation. All rights reserved. Apache Singa, Apache, the Apache feather logo, and the Apache Singa project logos are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.. + +

+
+ Built with Sphinx using a theme provided by Read the Docs. + +
+ +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + incubator-singa + v: latest + + +
+
+
Languages
+
English
+
中文
+
+
+
Versions
+
0.3
+
1.1
+
+ +
+ +
+ + + Fork me on GitHub + + + + + + + \ No newline at end of file Added: incubator/singa/site/trunk/v1.1.0/docs/dependencies.html URL: http://svn.apache.org/viewvc/incubator/singa/site/trunk/v1.1.0/docs/dependencies.html?rev=1782721&view=auto ============================================================================== --- incubator/singa/site/trunk/v1.1.0/docs/dependencies.html (added) +++ incubator/singa/site/trunk/v1.1.0/docs/dependencies.html Mon Feb 13 05:13:19 2017 @@ -0,0 +1,315 @@ + + + + + + + + + + + + Dependent library installation — incubator-singa 1.1.0 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+ + + + + + +
+
    +
  • Docs »
  • + +
  • Dependent library installation
  • +
  • + + + +
  • +
+
+
+
+
+ +
+

Dependent library installation¶

+
+

Windows¶

+

This section is used to compile and install the dependent libraries under +windows system from source codes. The following instructions ONLY work for Visual Studio 2015 as +previous VS does not support C++11 features well (including generic lambdas, auto, non-static +data member initializers). If you intend to generate a 32-bit/64-bit singa solution, please configure all the +VS projects for the dependent libraries as 32-bit/64-bit. This can be done by +“Configuration Manager” in VS 2015 or use corresponding generator in cmake. When compiling the following libraries, you +may get system-specific warnings/errors. Please fix them according to the +prompts by VS.

+
+

Google Logging¶

+

The glog library is an optional library for singa project. But it is currently necessary for Window compilation. +Since the latest release version of glog will encounter error C2084 on sprintf function +under VS2015, we test the compilation and installation using the master branch from github.

+

Step 1: Download and decompress the source code. Or use git clone https://github.com/google/glog to get the code.

+

Step 2: Open “glog.sln” file under project folder. You will get a conversion +dialog and please finish it by the prompts. Compile all the projects in the solution after +proper configuration, especially “libglog” and “libglog_static” projects.

+

Step 3: Copy all the header files and the entire directory named “glog” under +“src\windows“ folder into the installation include folder (or system folder). +Copy all the generated library files into the installation library folder (or +system folder).

+

Step 4: Done.

+
+
+

Google protobuf¶

+

Tested on version 2.6.1:

+

Step 1: Download and decompress the source code.

+

Step 2: Open “protobuf.sln” file under “vsprojects” folder. You will get a conversion +dialog and please finish it by the prompts. Compile all the projects in the solution after proper +configuration. Especially “libprotobuf”, “libprotobuf-lite”, “libprotoc” and +“protoc” projects.

+

Step 3: Run “extract_includes.bat” script under “vsprojects” folder, you will +get a new “include” folder with all the headers.

+

Step 4: Copy the library files, such as “libprotobuf.lib”, +“libprotobuf-lite.lib”, “libprotoc.lib”, etc., into your installation library folder (or +system folder). Copy the binary file “protoc” into your installation binary +folder (or system folder). Copy all the headers and folders in “include” folder into your +installation include folder (or system folder).

+

Step 5: Done.

+
+
+

CBLAS¶

+

There are ready-to-use binary packages online +(link). However, we still install +OpenBLAS with version 0.2.18 as test:

+

Step 1: Download and decompress the source code.

+

Step 2: Start a cmd window under the OpenBLAS folder then run the following +commands to generate the solution:

+
$ md build $$ cd build
+$ cmake -G "Visual Studio 14" ..
+
+
+

Or run cmake -G "Visual Studio 14 Win64" as you wish.

+

Step 3: Install Perl into your system and put perl.exe on your path. Open “OpenBlas.sln” and build the solution, especially “libopenblas” +project.

+

Step 4: Copy the library files under “build\lib” folder and all header files +under OpenBLAS folder into installation library and include folders (or system +folders).

+

Step 5: Done.

+
+
+
+

FAQ¶

+
    +
  1. Error C2375 ‘snprintf’: redefinition; different linkage

    +

    Add “HAVE_SNPRINTF” to “C/C++ - Preprocessor - Preprocessor definitions”

    +
  2. +
  3. Error due to hash map

    +

    Add “_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS” to Preprocessor Definitions.

    +
  4. +
+
+
+ + +
+
+
+ + +
+ +
+

+ © Copyright 2017 The Apache Software Foundation. All rights reserved. Apache Singa, Apache, the Apache feather logo, and the Apache Singa project logos are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.. + +

+
+ Built with Sphinx using a theme provided by Read the Docs. + +
+ +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + incubator-singa + v: latest + + +
+
+
Languages
+
English
+
中文
+
+
+
Versions
+
0.3
+
1.1
+
+ +
+ +
+ + + Fork me on GitHub + + + + + + + \ No newline at end of file Added: incubator/singa/site/trunk/v1.1.0/docs/device.html URL: http://svn.apache.org/viewvc/incubator/singa/site/trunk/v1.1.0/docs/device.html?rev=1782721&view=auto ============================================================================== --- incubator/singa/site/trunk/v1.1.0/docs/device.html (added) +++ incubator/singa/site/trunk/v1.1.0/docs/device.html Mon Feb 13 05:13:19 2017 @@ -0,0 +1,346 @@ + + + + + + + + + + + + Device — incubator-singa 1.1.0 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+ + + + + + +
+ +
+
+
+
+ +
+

Device¶

+

The Device abstract represents any hardware device with memory and compuation units. +All [Tensor operations](tensor.html) are scheduled by the resident device for execution. +Tensor memory is also managed by the device’s memory manager. Therefore, optimization +of memory and execution are implemented in the Device class.

+
+

Specific devices¶

+

Currently, SINGA has three Device implmentations,

+
    +
  1. CudaGPU for an Nvidia GPU card which runs Cuda code
  2. +
  3. CppCPU for a CPU which runs Cpp code
  4. +
  5. OpenclGPU for a GPU card which runs OpenCL code
  6. +
+
+
+

Python API¶

+

This script includes Device class and its subclasses for python users +to call singa::Device and its methods.

+

TODO(wangwei) implement py CudaGPU class.

+
+
+singa.device.create_cuda_gpus(num)¶
+

Create a list of CudaGPU devices.

+ +++ + + + + + +
Parameters:num (int) – number of device to create.
Returns:a list of swig converted CudaGPU devices.
+
+ +
+
+singa.device.create_cuda_gpus_on(device_ids)¶
+

Create a list of CudaGPU devices.

+ +++ + + + + + +
Parameters:device_ids (list) – a list of GPU card IDs.
Returns:a list of swig converted CudaGPU devices.
+
+ +
+
+singa.device.get_default_device()¶
+

Get the default host device which is a CppCPU device

+
+ +

The following code provides examples of creating devices:

+
from singa import device
+cuda = device.create_cuda_gpu_on(0)  # use GPU card of ID 0
+host = device.get_default_device()  # get the default host device (a CppCPU)
+ary1 = device.create_cuda_gpus(2)  # create 2 devices, starting from ID 0
+ary2 = device.create_cuda_gpus([0,2])  # create 2 devices on ID 0 and 2
+
+
+
+
+

CPP API¶

+
+
+ + +
+
+
+ + + + +
+ +
+

+ © Copyright 2017 The Apache Software Foundation. All rights reserved. Apache Singa, Apache, the Apache feather logo, and the Apache Singa project logos are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.. + +

+
+ Built with Sphinx using a theme provided by Read the Docs. + +
+ +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + incubator-singa + v: latest + + +
+
+
Languages
+
English
+
中文
+
+
+
Versions
+
0.3
+
1.1
+
+ +
+ +
+ + + Fork me on GitHub + + + + + + + \ No newline at end of file