versions/0.11.0/tutorials/r/symbol.html (341 lines of code) (raw):

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <meta content="IE=edge" http-equiv="X-UA-Compatible"/> <meta content="width=device-width, initial-scale=1" name="viewport"/> <meta content="Symbol and Automatic Differentiation" property="og:title"> <meta content="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/og-logo.png" property="og:image"> <meta content="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/og-logo.png" property="og:image:secure_url"> <meta content="Symbol and Automatic Differentiation" property="og:description"/> <title>Symbol and Automatic Differentiation — mxnet documentation</title> <link crossorigin="anonymous" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" rel="stylesheet"/> <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"/> <link href="../../_static/basic.css" rel="stylesheet" type="text/css"> <link href="../../_static/pygments.css" rel="stylesheet" type="text/css"> <link href="../../_static/mxnet.css" rel="stylesheet" type="text/css"/> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; </script> <script src="https://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script> <script src="../../_static/underscore.js" type="text/javascript"></script> <script src="../../_static/searchtools_custom.js" type="text/javascript"></script> <script src="../../_static/doctools.js" type="text/javascript"></script> <script src="../../_static/selectlang.js" type="text/javascript"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script> <script type="text/javascript"> jQuery(function() { Search.loadIndex("/versions/0.11.0/searchindex.js"); Search.init();}); </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="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> --> <!-- --> <link href="../../genindex.html" rel="index" title="Index"> <link href="../../search.html" rel="search" title="Search"/> <link href="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/mxnet-icon.png" rel="icon" type="image/png"/> </link></link></link></meta></meta></meta></head> <body background="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/mxnet-background-compressed.jpeg" role="document"> <div class="content-block"><div class="navbar navbar-fixed-top"> <div class="container" id="navContainer"> <div class="innder" id="header-inner"> <h1 id="logo-wrap"> <a href="../../" id="logo"><img src="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/mxnet_logo.png"/></a> </h1> <nav class="nav-bar" id="main-nav"> <a class="main-nav-link" href="/versions/0.11.0/get_started/install.html">Install</a> <span id="dropdown-menu-position-anchor"> <a aria-expanded="true" aria-haspopup="true" class="main-nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button">Gluon <span class="caret"></span></a> <ul class="dropdown-menu navbar-menu" id="package-dropdown-menu"> <li><a class="main-nav-link" href="/versions/0.11.0/tutorials/gluon/gluon.html">About</a></li> <li><a class="main-nav-link" href="https://www.d2l.ai/">Dive into Deep Learning</a></li> <li><a class="main-nav-link" href="https://gluon-cv.mxnet.io">GluonCV Toolkit</a></li> <li><a class="main-nav-link" href="https://gluon-nlp.mxnet.io/">GluonNLP Toolkit</a></li> </ul> </span> <span id="dropdown-menu-position-anchor"> <a aria-expanded="true" aria-haspopup="true" class="main-nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button">API <span class="caret"></span></a> <ul class="dropdown-menu navbar-menu" id="package-dropdown-menu"> <li><a class="main-nav-link" href="/versions/0.11.0/api/python/index.html">Python</a></li> <li><a class="main-nav-link" href="/versions/0.11.0/api/c++/index.html">C++</a></li> <li><a class="main-nav-link" href="/versions/0.11.0/api/julia/index.html">Julia</a></li> <li><a class="main-nav-link" href="/versions/0.11.0/api/perl/index.html">Perl</a></li> <li><a class="main-nav-link" href="/versions/0.11.0/api/r/index.html">R</a></li> <li><a class="main-nav-link" href="/versions/0.11.0/api/scala/index.html">Scala</a></li> </ul> </span> <span id="dropdown-menu-position-anchor-docs"> <a aria-expanded="true" aria-haspopup="true" class="main-nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button">Docs <span class="caret"></span></a> <ul class="dropdown-menu navbar-menu" id="package-dropdown-menu-docs"> <li><a class="main-nav-link" href="/versions/0.11.0/how_to/faq.html">FAQ</a></li> <li><a class="main-nav-link" href="/versions/0.11.0/tutorials/index.html">Tutorials</a> <li><a class="main-nav-link" href="https://github.com/apache/incubator-mxnet/tree/v0.11.0/example">Examples</a></li> <li><a class="main-nav-link" href="/versions/0.11.0/architecture/index.html">Architecture</a></li> <li><a class="main-nav-link" href="https://cwiki.apache.org/confluence/display/MXNET/Apache+MXNet+Home">Developer Wiki</a></li> <li><a class="main-nav-link" href="/versions/0.11.0/model_zoo/index.html">Model Zoo</a></li> <li><a class="main-nav-link" href="https://github.com/onnx/onnx-mxnet">ONNX</a></li> </li></ul> </span> <span id="dropdown-menu-position-anchor-community"> <a aria-expanded="true" aria-haspopup="true" class="main-nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button">Community <span class="caret"></span></a> <ul class="dropdown-menu navbar-menu" id="package-dropdown-menu-community"> <li><a class="main-nav-link" href="http://discuss.mxnet.io">Forum</a></li> <li><a class="main-nav-link" href="https://github.com/apache/incubator-mxnet/tree/v0.11.0">Github</a></li> <li><a class="main-nav-link" href="/versions/0.11.0/community/contribute.html">Contribute</a></li> </ul> </span> <span id="dropdown-menu-position-anchor-version" style="position: relative"><a href="#" class="main-nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true">0.11.0<span class="caret"></span></a><ul id="package-dropdown-menu" class="dropdown-menu"><li><a href="/">master</a></li><li><a href="/versions/1.7.0/">1.7.0</a></li><li><a href=/versions/1.6.0/>1.6.0</a></li><li><a href=/versions/1.5.0/>1.5.0</a></li><li><a href=/versions/1.4.1/>1.4.1</a></li><li><a href=/versions/1.3.1/>1.3.1</a></li><li><a href=/versions/1.2.1/>1.2.1</a></li><li><a href=/versions/1.1.0/>1.1.0</a></li><li><a href=/versions/1.0.0/>1.0.0</a></li><li><a href=/versions/0.12.1/>0.12.1</a></li><li><a href=/versions/0.11.0/>0.11.0</a></li></ul></span></nav> <script> function getRootPath(){ return "../../" } </script> <div class="burgerIcon dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button">☰</a> <ul class="dropdown-menu" id="burgerMenu"> <li><a href="/versions/0.11.0/get_started/install.html">Install</a></li> <li><a class="main-nav-link" href="/versions/0.11.0/tutorials/index.html">Tutorials</a></li> <li class="dropdown-submenu dropdown"> <a aria-expanded="true" aria-haspopup="true" class="dropdown-toggle burger-link" data-toggle="dropdown" href="#" tabindex="-1">Gluon</a> <ul class="dropdown-menu navbar-menu" id="package-dropdown-menu"> <li><a class="main-nav-link" href="/versions/0.11.0/tutorials/gluon/gluon.html">About</a></li> <li><a class="main-nav-link" href="http://gluon.mxnet.io">The Straight Dope (Tutorials)</a></li> <li><a class="main-nav-link" href="https://gluon-cv.mxnet.io">GluonCV Toolkit</a></li> <li><a class="main-nav-link" href="https://gluon-nlp.mxnet.io/">GluonNLP Toolkit</a></li> </ul> </li> <li class="dropdown-submenu"> <a aria-expanded="true" aria-haspopup="true" class="dropdown-toggle burger-link" data-toggle="dropdown" href="#" tabindex="-1">API</a> <ul class="dropdown-menu"> <li><a class="main-nav-link" href="/versions/0.11.0/api/python/index.html">Python</a></li> <li><a class="main-nav-link" href="/versions/0.11.0/api/c++/index.html">C++</a></li> <li><a class="main-nav-link" href="/versions/0.11.0/api/julia/index.html">Julia</a></li> <li><a class="main-nav-link" href="/versions/0.11.0/api/perl/index.html">Perl</a></li> <li><a class="main-nav-link" href="/versions/0.11.0/api/r/index.html">R</a></li> <li><a class="main-nav-link" href="/versions/0.11.0/api/scala/index.html">Scala</a></li> </ul> </li> <li class="dropdown-submenu"> <a aria-expanded="true" aria-haspopup="true" class="dropdown-toggle burger-link" data-toggle="dropdown" href="#" tabindex="-1">Docs</a> <ul class="dropdown-menu"> <li><a href="/versions/0.11.0/how_to/faq.html" tabindex="-1">FAQ</a></li> <li><a href="/versions/0.11.0/tutorials/index.html" tabindex="-1">Tutorials</a></li> <li><a href="https://github.com/apache/incubator-mxnet/tree/v0.11.0/example" tabindex="-1">Examples</a></li> <li><a href="/versions/0.11.0/architecture/index.html" tabindex="-1">Architecture</a></li> <li><a href="https://cwiki.apache.org/confluence/display/MXNET/Apache+MXNet+Home" tabindex="-1">Developer Wiki</a></li> <li><a href="/versions/0.11.0/model_zoo/index.html" tabindex="-1">Gluon Model Zoo</a></li> <li><a href="https://github.com/onnx/onnx-mxnet" tabindex="-1">ONNX</a></li> </ul> </li> <li class="dropdown-submenu dropdown"> <a aria-haspopup="true" class="dropdown-toggle burger-link" data-toggle="dropdown" href="#" role="button" tabindex="-1">Community</a> <ul class="dropdown-menu"> <li><a href="http://discuss.mxnet.io" tabindex="-1">Forum</a></li> <li><a href="https://github.com/apache/incubator-mxnet/tree/v0.11.0" tabindex="-1">Github</a></li> <li><a href="/versions/0.11.0/community/contribute.html" tabindex="-1">Contribute</a></li> </ul> </li> <li id="dropdown-menu-position-anchor-version-mobile" class="dropdown-submenu" style="position: relative"><a href="#" tabindex="-1">0.11.0</a><ul class="dropdown-menu"><li><a tabindex="-1" href=/>master</a></li><li><a tabindex="-1" href=/versions/1.6.0/>1.6.0</a></li><li><a tabindex="-1" href=/versions/1.5.0/>1.5.0</a></li><li><a tabindex="-1" href=/versions/1.4.1/>1.4.1</a></li><li><a tabindex="-1" href=/versions/1.3.1/>1.3.1</a></li><li><a tabindex="-1" href=/versions/1.2.1/>1.2.1</a></li><li><a tabindex="-1" href=/versions/1.1.0/>1.1.0</a></li><li><a tabindex="-1" href=/versions/1.0.0/>1.0.0</a></li><li><a tabindex="-1" href=/versions/0.12.1/>0.12.1</a></li><li><a tabindex="-1" href=/versions/0.11.0/>0.11.0</a></li></ul></li></ul> </div> <div class="plusIcon dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button"><span aria-hidden="true" class="glyphicon glyphicon-plus"></span></a> <ul class="dropdown-menu dropdown-menu-right" id="plusMenu"></ul> </div> <div id="search-input-wrap"> <form action="../../search.html" autocomplete="off" class="" method="get" role="search"> <div class="form-group inner-addon left-addon"> <i class="glyphicon glyphicon-search"></i> <input class="form-control" name="q" placeholder="Search" type="text"/> </div> <input name="check_keywords" type="hidden" value="yes"> <input name="area" type="hidden" value="default"/> </input></form> <div id="search-preview"></div> </div> <div id="searchIcon"> <span aria-hidden="true" class="glyphicon glyphicon-search"></span> </div> <!-- <div id="lang-select-wrap"> --> <!-- <label id="lang-select-label"> --> <!-- <\!-- <i class="fa fa-globe"></i> -\-> --> <!-- <span></span> --> <!-- </label> --> <!-- <select id="lang-select"> --> <!-- <option value="en">Eng</option> --> <!-- <option value="zh">中文</option> --> <!-- </select> --> <!-- </div> --> <!-- <a id="mobile-nav-toggle"> <span class="mobile-nav-toggle-bar"></span> <span class="mobile-nav-toggle-bar"></span> <span class="mobile-nav-toggle-bar"></span> </a> --> </div> </div> </div> <script type="text/javascript"> $('body').css('background', 'white'); </script> <div class="container"> <div class="row"> <div aria-label="main navigation" class="sphinxsidebar leftsidebar" role="navigation"> <div class="sphinxsidebarwrapper"> <ul> <li class="toctree-l1"><a class="reference internal" href="../../api/python/index.html">Python Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../../api/r/index.html">R Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../../api/julia/index.html">Julia Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../../api/c++/index.html">C++ Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../../api/scala/index.html">Scala Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../../api/perl/index.html">Perl Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../../how_to/index.html">HowTo Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../../architecture/index.html">System Documents</a></li> <li class="toctree-l1"><a class="reference internal" href="../index.html">Tutorials</a></li> </ul> </div> </div> <div class="content"> <div class="page-tracker"></div> <div class="section" id="symbol-and-automatic-differentiation"> <span id="symbol-and-automatic-differentiation"></span><h1>Symbol and Automatic Differentiation<a class="headerlink" href="#symbol-and-automatic-differentiation" title="Permalink to this headline">¶</a></h1> <p>The computational unit <code class="docutils literal"><span class="pre">NDArray</span></code> requires a way to construct neural networks. MXNet provides a symbolic interface, named Symbol, to do this. Symbol combines both flexibility and efficiency.</p> <div class="section" id="basic-composition-of-symbols"> <span id="basic-composition-of-symbols"></span><h2>Basic Composition of Symbols<a class="headerlink" href="#basic-composition-of-symbols" title="Permalink to this headline">¶</a></h2> <p>The following code creates a two-layer perceptron network:</p> <div class="highlight-r"><div class="highlight"><pre><span></span><span class="nf">require</span><span class="p">(</span><span class="n">mxnet</span><span class="p">)</span> <span class="n">net</span> <span class="o"><-</span> <span class="nf">mx.symbol.Variable</span><span class="p">(</span><span class="s">"data"</span><span class="p">)</span> <span class="n">net</span> <span class="o"><-</span> <span class="nf">mx.symbol.FullyConnected</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">net</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">"fc1"</span><span class="p">,</span> <span class="n">num_hidden</span><span class="o">=</span><span class="m">128</span><span class="p">)</span> <span class="n">net</span> <span class="o"><-</span> <span class="nf">mx.symbol.Activation</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">net</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">"relu1"</span><span class="p">,</span> <span class="n">act_type</span><span class="o">=</span><span class="s">"relu"</span><span class="p">)</span> <span class="n">net</span> <span class="o"><-</span> <span class="nf">mx.symbol.FullyConnected</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">net</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">"fc2"</span><span class="p">,</span> <span class="n">num_hidden</span><span class="o">=</span><span class="m">64</span><span class="p">)</span> <span class="n">net</span> <span class="o"><-</span> <span class="nf">mx.symbol.Softmax</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">net</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">"out"</span><span class="p">)</span> <span class="nf">class</span><span class="p">(</span><span class="n">net</span><span class="p">)</span> </pre></div> </div> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="c1">## [1] "Rcpp_MXSymbol"</span> <span class="c1">## attr(,"package")</span> <span class="c1">## [1] "mxnet"</span> </pre></div> </div> <p>Each symbol takes a (unique) string name. <em>Variable</em> often defines the inputs, or free variables. Other symbols take a symbol as the input (<em>data</em>), and may accept other hyper parameters, such as the number of hidden neurons (<em>num_hidden</em>) or the activation type (<em>act_type</em>).</p> <p>A symbol can be viewed as a function that takes several arguments, whose names are automatically generated and can be retrieved with the following command:</p> <div class="highlight-r"><div class="highlight"><pre><span></span><span class="nf">arguments</span><span class="p">(</span><span class="n">net</span><span class="p">)</span> </pre></div> </div> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="c1">## [1] "data" "fc1_weight" "fc1_bias" "fc2_weight" "fc2_bias"</span> <span class="c1">## [6] "out_label"</span> </pre></div> </div> <p>The arguments are the parameters need by each symbol:</p> <ul class="simple"> <li><em>data</em>: Input data needed by the variable <em>data</em></li> <li><em>fc1_weight</em> and <em>fc1_bias</em>: The weight and bias for the first fully connected layer, <em>fc1</em></li> <li><em>fc2_weight</em> and <em>fc2_bias</em>: The weight and bias for the second fully connected layer, <em>fc2</em></li> <li><em>out_label</em>: The label needed by the loss</li> </ul> <p>We can also specify the automatically generated names explicitly:</p> <div class="highlight-r"><div class="highlight"><pre><span></span><span class="n">data</span> <span class="o"><-</span> <span class="nf">mx.symbol.Variable</span><span class="p">(</span><span class="s">"data"</span><span class="p">)</span> <span class="n">w</span> <span class="o"><-</span> <span class="nf">mx.symbol.Variable</span><span class="p">(</span><span class="s">"myweight"</span><span class="p">)</span> <span class="n">net</span> <span class="o"><-</span> <span class="nf">mx.symbol.FullyConnected</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">,</span> <span class="n">weight</span><span class="o">=</span><span class="n">w</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">"fc1"</span><span class="p">,</span> <span class="n">num_hidden</span><span class="o">=</span><span class="m">128</span><span class="p">)</span> <span class="nf">arguments</span><span class="p">(</span><span class="n">net</span><span class="p">)</span> </pre></div> </div> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="c1">## [1] "data" "myweight" "fc1_bias"</span> </pre></div> </div> </div> <div class="section" id="more-complicated-composition-of-symbols"> <span id="more-complicated-composition-of-symbols"></span><h2>More Complicated Composition of Symbols<a class="headerlink" href="#more-complicated-composition-of-symbols" title="Permalink to this headline">¶</a></h2> <p>MXNet provides well-optimized symbols for commonly used layers in deep learning. You can also define new operators in Python. The following example first performs an element-wise add between two symbols, then feeds them to the fully connected operator:</p> <div class="highlight-r"><div class="highlight"><pre><span></span><span class="n">lhs</span> <span class="o"><-</span> <span class="nf">mx.symbol.Variable</span><span class="p">(</span><span class="s">"data1"</span><span class="p">)</span> <span class="n">rhs</span> <span class="o"><-</span> <span class="nf">mx.symbol.Variable</span><span class="p">(</span><span class="s">"data2"</span><span class="p">)</span> <span class="n">net</span> <span class="o"><-</span> <span class="nf">mx.symbol.FullyConnected</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">lhs</span> <span class="o">+</span> <span class="n">rhs</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">"fc1"</span><span class="p">,</span> <span class="n">num_hidden</span><span class="o">=</span><span class="m">128</span><span class="p">)</span> <span class="nf">arguments</span><span class="p">(</span><span class="n">net</span><span class="p">)</span> </pre></div> </div> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="c1">## [1] "data1" "data2" "fc1_weight" "fc1_bias"</span> </pre></div> </div> <p>We can construct a symbol more flexibly than by using the single forward composition, for example:</p> <div class="highlight-r"><div class="highlight"><pre><span></span><span class="n">net</span> <span class="o"><-</span> <span class="nf">mx.symbol.Variable</span><span class="p">(</span><span class="s">"data"</span><span class="p">)</span> <span class="n">net</span> <span class="o"><-</span> <span class="nf">mx.symbol.FullyConnected</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">net</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">"fc1"</span><span class="p">,</span> <span class="n">num_hidden</span><span class="o">=</span><span class="m">128</span><span class="p">)</span> <span class="n">net2</span> <span class="o"><-</span> <span class="nf">mx.symbol.Variable</span><span class="p">(</span><span class="s">"data2"</span><span class="p">)</span> <span class="n">net2</span> <span class="o"><-</span> <span class="nf">mx.symbol.FullyConnected</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">net2</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">"net2"</span><span class="p">,</span> <span class="n">num_hidden</span><span class="o">=</span><span class="m">128</span><span class="p">)</span> <span class="n">composed.net</span> <span class="o"><-</span> <span class="nf">mx.apply</span><span class="p">(</span><span class="n">net</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">net2</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">"compose"</span><span class="p">)</span> <span class="nf">arguments</span><span class="p">(</span><span class="n">composed.net</span><span class="p">)</span> </pre></div> </div> <div class="highlight-default"><div class="highlight"><pre><span></span><span class="c1">## [1] "data2" "net2_weight" "net2_bias" "fc1_weight" "fc1_bias"</span> </pre></div> </div> <p>In the example, <em>net</em> is used as a function to apply to an existing symbol <em>net</em>. The resulting <em>composed.net</em> will replace the original argument <em>data</em> with <em>net2</em> instead.</p> </div> <div class="section" id="training-a-neural-net"> <span id="training-a-neural-net"></span><h2>Training a Neural Net<a class="headerlink" href="#training-a-neural-net" title="Permalink to this headline">¶</a></h2> <p>The <a class="reference external" href="/versions/0.11.0/../R-package/R/model.R">model API</a> is a thin wrapper around the symbolic executors to support neural net training.</p> <p>We encourage you to read <a class="reference external" href="/versions/0.11.0/tutorials/python/symbol_in_pictures.md">Symbolic Configuration and Execution in Pictures for python package</a>for a detailed explanation of concepts in pictures.</p> </div> <div class="section" id="how-efficient-is-the-symbolic-api"> <span id="how-efficient-is-the-symbolic-api"></span><h2>How Efficient Is the Symbolic API?<a class="headerlink" href="#how-efficient-is-the-symbolic-api" title="Permalink to this headline">¶</a></h2> <p>The Symbolic API brings the efficient C++ operations in powerful toolkits, such as CXXNet and Caffe, together with the flexible dynamic NDArray operations. All of the memory and computation resources are allocated statically during bind operations, to maximize runtime performance and memory utilization.</p> <p>The coarse-grained operators are equivalent to CXXNet layers, which are extremely efficient. We also provide fine-grained operators for more flexible composition. Because MXNet does more in-place memory allocation, it can be more memory efficient than CXXNet and gets to the same runtime with greater flexibility.</p> </div> <div class="section" id="next-steps"> <span id="next-steps"></span><h2>Next Steps<a class="headerlink" href="#next-steps" title="Permalink to this headline">¶</a></h2> <div class="toctree-wrapper compound"> <ul> <li class="toctree-l1"><a class="reference external" href="/versions/0.11.0/tutorials/r/CallbackFunctionTutorial.html">Write and use callback functions</a></li> <li class="toctree-l1"><a class="reference external" href="/versions/0.11.0/tutorials/r/fiveMinutesNeuralNetwork.html">Neural Networks with MXNet in Five Minutes</a></li> <li class="toctree-l1"><a class="reference external" href="/versions/0.11.0/tutorials/r/classifyRealImageWithPretrainedModel.html">Classify Real-World Images with Pre-trained Model</a></li> <li class="toctree-l1"><a class="reference external" href="/versions/0.11.0/tutorials/r/mnistCompetition.html">Handwritten Digits Classification Competition</a></li> <li class="toctree-l1"><a class="reference external" href="/versions/0.11.0/tutorials/r/charRnnModel.html">Character Language Model using RNN</a></li> </ul> </div> </div> </div> </div> </div> <div aria-label="main navigation" class="sphinxsidebar rightsidebar" role="navigation"> <div class="sphinxsidebarwrapper"> <h3><a href="../../index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Symbol and Automatic Differentiation</a><ul> <li><a class="reference internal" href="#basic-composition-of-symbols">Basic Composition of Symbols</a></li> <li><a class="reference internal" href="#more-complicated-composition-of-symbols">More Complicated Composition of Symbols</a></li> <li><a class="reference internal" href="#training-a-neural-net">Training a Neural Net</a></li> <li><a class="reference internal" href="#how-efficient-is-the-symbolic-api">How Efficient Is the Symbolic API?</a></li> <li><a class="reference internal" href="#next-steps">Next Steps</a></li> </ul> </li> </ul> </div> </div> </div><div class="footer"> <div class="section-disclaimer"> <div class="container"> <div> <img height="60" src="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/apache_incubator_logo.png"/> <p> Apache MXNet is an effort undergoing incubation at The Apache Software Foundation (ASF), <strong>sponsored by the <i>Apache Incubator</i></strong>. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF. </p> <p> "Copyright © 2017-2018, The Apache Software Foundation Apache MXNet, MXNet, Apache, the Apache feather, and the Apache MXNet project logo are either registered trademarks or trademarks of the Apache Software Foundation." </p> </div> </div> </div> </div> <!-- pagename != index --> </div> <script crossorigin="anonymous" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <script src="../../_static/js/sidebar.js" type="text/javascript"></script> <script src="../../_static/js/search.js" type="text/javascript"></script> <script src="../../_static/js/navbar.js" type="text/javascript"></script> <script src="../../_static/js/clipboard.min.js" type="text/javascript"></script> <script src="../../_static/js/copycode.js" type="text/javascript"></script> <script src="../../_static/js/page.js" type="text/javascript"></script> <script src="../../_static/js/docversion.js" type="text/javascript"></script> <script type="text/javascript"> $('body').ready(function () { $('body').css('visibility', 'visible'); }); </script> </body> </html>