| |
| |
| |
| <!DOCTYPE html> |
| <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> |
| <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> |
| <head> |
| <meta charset="utf-8"> |
| |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| |
| <title>Running instructions for CPP version — incubator-singa 1.1.0 documentation</title> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> |
| |
| |
| |
| |
| |
| <link rel="top" title="incubator-singa 1.1.0 documentation" href="../index.html"/> |
| <link href="../_static/style.css" rel="stylesheet" type="text/css"> |
| |
| |
| |
| <script src="../_static/js/modernizr.min.js"></script> |
| |
| </head> |
| |
| <body class="wy-body-for-nav" role="document"> |
| |
| <div class="wy-grid-for-nav"> |
| |
| |
| <nav data-toggle="wy-nav-shift" class="wy-nav-side"> |
| <div class="wy-side-scroll"> |
| <div class="wy-side-nav-search"> |
| |
| |
| |
| <a href="../index.html" class="icon icon-home"> incubator-singa |
| |
| |
| |
| |
| <img src="../_static/singa.png" class="logo" /> |
| |
| </a> |
| |
| |
| |
| |
| <div class="version"> |
| latest |
| </div> |
| |
| |
| |
| |
| <div role="search"> |
| <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> |
| <input type="text" name="q" placeholder="Search docs" /> |
| <input type="hidden" name="check_keywords" value="yes" /> |
| <input type="hidden" name="area" value="default" /> |
| </form> |
| </div> |
| |
| |
| </div> |
| |
| <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> |
| |
| |
| |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../downloads.html">Download SINGA</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="index.html">Documentation</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Development</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../develop/schedule.html">Development Schedule</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../develop/how-contribute.html">How to Contribute to SINGA</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../develop/contribute-code.html">How to Contribute Code</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../develop/contribute-docs.html">How to Contribute to Documentation</a></li> |
| </ul> |
| <p class="caption"><span class="caption-text">Community</span></p> |
| <ul> |
| <li class="toctree-l1"><a class="reference internal" href="../community/source-repository.html">Source Repository</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../community/mail-lists.html">Project Mailing Lists</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../community/issue-tracking.html">Issue Tracking</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../community/team-list.html">The SINGA Team</a></li> |
| </ul> |
| |
| |
| |
| </div> |
| </div> |
| </nav> |
| |
| <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> |
| |
| |
| <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> |
| <i data-toggle="wy-nav-top" class="fa fa-bars"></i> |
| <a href="../index.html">incubator-singa</a> |
| </nav> |
| |
| |
| |
| <div class="wy-nav-content"> |
| <div class="rst-content"> |
| |
| |
| |
| |
| |
| |
| <div role="navigation" aria-label="breadcrumbs navigation"> |
| <ul class="wy-breadcrumbs"> |
| <li><a href="../index.html">Docs</a> »</li> |
| |
| <li>Running instructions for CPP version</li> |
| <li class="wy-breadcrumbs-aside"> |
| |
| |
| |
| </li> |
| </ul> |
| <hr/> |
| </div> |
| <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> |
| <div itemprop="articleBody"> |
| |
| <p>#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 <a class="reference external" href="http://www.cs.toronto.edu/~kriz/cifar.html">CIFAR10 dataset</a>.</p> |
| <div class="section" id="running-instructions-for-cpp-version"> |
| <span id="running-instructions-for-cpp-version"></span><h1>Running instructions for CPP version<a class="headerlink" href="#running-instructions-for-cpp-version" title="Permalink to this headline">¶</a></h1> |
| <p>Please refer to <a class="reference external" href="installation.html">Installation</a> 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.</p> |
| <p>The Cifar10 dataset could be downloaded by running</p> |
| <div class="highlight-python"><div class="highlight"><pre># switch to cifar10 directory |
| $ cd ../examples/cifar10 |
| # download data for CPP version |
| $ python download_data.py bin |
| </pre></div> |
| </div> |
| <p>‘bin’ is for downloading binary version of Cifar10 data.</p> |
| <p>During downloading, you should see the detailed output like</p> |
| <div class="highlight-python"><div class="highlight"><pre> Downloading CIFAR10 from http://www.cs.toronto.edu/~kriz/cifar-10-binary.tar.gz |
| The tar file does exist. Extracting it now.. |
| Finished! |
| </pre></div> |
| </div> |
| <p>Now you have prepared the data for this Cifar10 example, the final step is to execute the <code class="docutils literal"><span class="pre">run.sh</span></code> script,</p> |
| <div class="highlight-python"><div class="highlight"><pre># in SINGA_ROOT/examples/cifar10/ |
| $ ./run.sh |
| </pre></div> |
| </div> |
| <p>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 <code class="docutils literal"><span class="pre">run.sh</span></code> file.</p> |
| <div class="highlight-python"><div class="highlight"><pre>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 |
| </pre></div> |
| </div> |
| <p>The training details are stored in <code class="docutils literal"><span class="pre">train_perf</span></code> file in the same directory and the validation details in <code class="docutils literal"><span class="pre">val_perf</span></code> file.</p> |
| </div> |
| <div class="section" id="running-instructions-for-python-version"> |
| <span id="running-instructions-for-python-version"></span><h1>Running instructions for Python version<a class="headerlink" href="#running-instructions-for-python-version" title="Permalink to this headline">¶</a></h1> |
| <p>To run CNN example in Python version, we need to compile SINGA with Python binding,</p> |
| <div class="highlight-python"><div class="highlight"><pre>$ mkdir build && cd build |
| $ cmake -DUSE_PYTHON=ON .. |
| $ make |
| </pre></div> |
| </div> |
| <p>Now download the Cifar10 dataset,</p> |
| <div class="highlight-python"><div class="highlight"><pre># switch to cifar10 directory |
| $ cd ../examples/cifar10 |
| # download data for Python version |
| $ python download_data.py py |
| </pre></div> |
| </div> |
| <p>During downloading, you should see the detailed output like</p> |
| <div class="highlight-python"><div class="highlight"><pre> Downloading CIFAR10 from http://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz |
| The tar file does exist. Extracting it now.. |
| Finished! |
| </pre></div> |
| </div> |
| <p>Then execute the <code class="docutils literal"><span class="pre">train.py</span></code> script to build the model</p> |
| <div class="highlight-python"><div class="highlight"><pre>$ python train.py |
| </pre></div> |
| </div> |
| <p>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.</p> |
| <div class="highlight-python"><div class="highlight"><pre>(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 |
| </pre></div> |
| </div> |
| <p>This script will call <code class="docutils literal"><span class="pre">alexnet.py</span></code> file to build the alexnet model. After the training is finished, SINGA will save the model parameters into a checkpoint file <code class="docutils literal"><span class="pre">model.bin</span></code> in the same directory. Then we can use this <code class="docutils literal"><span class="pre">model.bin</span></code> file for prediction.</p> |
| <div class="highlight-python"><div class="highlight"><pre>$ python predict.py |
| </pre></div> |
| </div> |
| </div> |
| |
| |
| </div> |
| </div> |
| <footer> |
| |
| |
| <hr/> |
| |
| <div role="contentinfo"> |
| <p> |
| © 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.. |
| |
| </p> |
| </div> |
| Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. |
| |
| </footer> |
| |
| </div> |
| </div> |
| |
| </section> |
| |
| </div> |
| |
| |
| |
| |
| |
| <script type="text/javascript"> |
| var DOCUMENTATION_OPTIONS = { |
| URL_ROOT:'../', |
| VERSION:'1.1.0', |
| COLLAPSE_INDEX:false, |
| FILE_SUFFIX:'.html', |
| HAS_SOURCE: true |
| }; |
| </script> |
| <script type="text/javascript" src="../_static/jquery.js"></script> |
| <script type="text/javascript" src="../_static/underscore.js"></script> |
| <script type="text/javascript" src="../_static/doctools.js"></script> |
| |
| |
| |
| |
| |
| <script type="text/javascript" src="../_static/js/theme.js"></script> |
| |
| |
| |
| |
| <script type="text/javascript"> |
| jQuery(function () { |
| SphinxRtdTheme.StickyNav.enable(); |
| }); |
| </script> |
| |
| |
| <div class="rst-versions shift-up" data-toggle="rst-versions" role="note" aria-label="versions"> |
| <span class="rst-current-version" data-toggle="rst-current-version"> |
| <span class="fa fa-book"> incubator-singa </span> |
| v: latest |
| <span class="fa fa-caret-down"></span> |
| </span> |
| <div class="rst-other-versions"> |
| <dl> |
| <dt>Languages</dt> |
| <dd><a href="../../en/index.html">English</a></dd> |
| <dd><a href="../../zh/index.html">中文</a></dd> |
| </dl> |
| <dl> |
| <dt>Versions</dt> |
| <dd><a href="http://singa.apache.org/v0.3.0/">0.3</a></dd> |
| <dd><a href="http://singa.apache.org/v1.1.0/">1.1</a></dd> |
| </dl> |
| |
| </div> |
| <a href="http://incubator.apache.org/"> <img src= "../_static/apache.jpg"> </a> |
| </div> |
| |
| <a href="https://github.com/apache/incubator-singa"> |
| <img style="position: absolute; top: 0; right: 0; border: 0; z-index: 10000;" |
| src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png" |
| alt="Fork me on GitHub"> |
| </a> |
| |
| |
| |
| |
| </body> |
| </html> |