blob: 112b52d82413aa0a2206ebda387bf1b75f06726a [file] [log] [blame]
<!DOCTYPE html >
<html>
<head>
<title>module - MXNet - org.apache.mxnet.module</title>
<meta name="description" content="module - MXNet - org.apache.mxnet.module" />
<meta name="keywords" content="module MXNet org.apache.mxnet.module" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link href="../../../../lib/template.css" media="screen" type="text/css" rel="stylesheet" />
<link href="../../../../lib/diagrams.css" media="screen" type="text/css" rel="stylesheet" id="diagrams-css" />
<script type="text/javascript" src="../../../../lib/jquery.js" id="jquery-js"></script>
<script type="text/javascript" src="../../../../lib/jquery-ui.js"></script>
<script type="text/javascript" src="../../../../lib/template.js"></script>
<script type="text/javascript" src="../../../../lib/tools.tooltip.js"></script>
<script type="text/javascript">
if(top === self) {
var url = '../../../../index.html';
var hash = 'org.apache.mxnet.module.package';
var anchor = window.location.hash;
var anchor_opt = '';
if (anchor.length >= 1)
anchor_opt = '@' + anchor.substring(1);
window.location.href = url + '#' + hash + anchor_opt;
}
</script>
</head>
<body class="value">
<div id="definition">
<img src="../../../../lib/package_big.png" />
<p id="owner"><a href="../../../package.html" class="extype" name="org">org</a>.<a href="../../package.html" class="extype" name="org.apache">apache</a>.<a href="../package.html" class="extype" name="org.apache.mxnet">mxnet</a></p>
<h1>module</h1><span class="permalink">
<a href="../../../../index.html#org.apache.mxnet.module.package" title="Permalink" target="_top">
<img src="../../../../lib/permalink.png" />
</a>
</span>
</div>
<h4 id="signature" class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">package</span>
</span>
<span class="symbol">
<span class="name">module</span>
</span>
</h4>
<div id="comment" class="fullcommenttop"></div>
<div id="mbrsel">
<div id="textfilter"><span class="pre"></span><span class="input"><input id="mbrsel-input" type="text" accesskey="/" /></span><span class="post"></span></div>
<div id="visbl">
<span class="filtertype">Visibility</span>
<ol><li class="public in"><span>Public</span></li><li class="all out"><span>All</span></li></ol>
</div>
</div>
<div id="template">
<div id="allMembers">
<div id="types" class="types members">
<h3>Type Members</h3>
<ol><li name="org.apache.mxnet.module.BaseModule" visbl="pub" data-isabs="true" fullComment="yes" group="Ungrouped">
<a id="BaseModuleextendsAnyRef"></a>
<a id="BaseModule:BaseModule"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier">abstract </span>
<span class="kind">class</span>
</span>
<span class="symbol">
<a href="BaseModule.html"><span class="name">BaseModule</span></a><span class="result"> extends <span class="extype" name="scala.AnyRef">AnyRef</span></span>
</span>
</h4><span class="permalink">
<a href="../../../../index.html#org.apache.mxnet.module.package@BaseModuleextendsAnyRef" title="Permalink" target="_top">
<img src="../../../../lib/permalink.png" />
</a>
</span>
<p class="shortcomment cmt">The base class of a modules.</p><div class="fullcomment"><div class="comment cmt"><p>The base class of a modules. A module represents a computation component. The design
purpose of a module is that it abstract a computation &quot;machine&quot;, that one can run forward,
backward, update parameters, etc. We aim to make the APIs easy to use, especially in the
case when we need to use imperative API to work with multiple modules (e.g. stochastic
depth network).</p><p>A module has several states:</p><p>- Initial state. Memory is not allocated yet, not ready for computation yet.
- Binded. Shapes for inputs, outputs, and parameters are all known, memory allocated,
ready for computation.
- Parameter initialized. For modules with parameters, doing computation before initializing
the parameters might result in undefined outputs.
- Optimizer installed. An optimizer can be installed to a module. After this, the parameters
of the module can be updated according to the optimizer after gradients are computed
(forward-backward).</p><p> In order for a module to interactive with others, a module should be able to report the
following information in its raw stage (before binded)</p><ul><li><code>data_names</code>: list of string indicating the names of required data.</li><li><code>output_names</code>: list of string indicating the names of required outputs.</li></ul><p> And also the following richer information after binded:</p><ul><li>state information<ul><li><code>binded</code>: <code>bool</code>, indicating whether the memory buffers needed for computation
has been allocated.</li><li><code>forTraining</code>: whether the module is binded for training (if binded).</li><li><code>paramsInitialized</code>: <code>bool</code>, indicating whether the parameters of this modules
has been initialized.</li><li><code>optimizerInitialized</code>: <code>bool</code>, indicating whether an optimizer is defined
and initialized.</li><li><code>inputsNeedGrad</code>: <code>bool</code>, indicating whether gradients with respect to the
input data is needed. Might be useful when implementing composition of modules.</li></ul></li><li>input/output information<ul><li><code>dataShapes</code>: a list of <code>(name, shape)</code>. In theory, since the memory is allocated,
we could directly provide the data arrays. But in the case of data parallelization,
the data arrays might not be of the same shape as viewed from the external world.</li><li><code>labelShapes</code>: a list of <code>(name, shape)</code>. This might be <code>[]</code> if the module does
not need labels (e.g. it does not contains a loss function at the top), or a module
is not binded for training.</li><li><code>outputShapes</code>: a list of <code>(name, shape)</code> for outputs of the module.</li></ul></li><li>parameters (for modules with parameters)<ul><li><code>getParams()</code>: return a tuple <code>(argParams, auxParams)</code>. Each of those
is a dictionary of name to <code>NDArray</code> mapping. Those <code>NDArray</code> always lives on
CPU. The actual parameters used for computing might live on other devices (GPUs),
this function will retrieve (a copy of) the latest parameters. Therefore, modifying</li><li><code>setParams(argParams, auxParams)</code>: assign parameters to the devices
doing the computation.</li><li><code>initParams(...)</code>: a more flexible interface to assign or initialize the parameters.</li></ul></li><li>setup<ul><li><code>bind()</code>: prepare environment for computation.</li><li><code>initOptimizer()</code>: install optimizer for parameter updating.</li></ul></li><li>computation<ul><li><code>forward(dataBatch)</code>: forward operation.</li><li><code>backward(outGrads=None)</code>: backward operation.</li><li><code>update()</code>: update parameters according to installed optimizer.</li><li><code>getOutputs()</code>: get outputs of the previous forward operation.</li><li><code>getInputGrads()</code>: get the gradients with respect to the inputs computed
in the previous backward operation.</li><li><code>updateMetric(metric, labels)</code>: update performance metric for the previous forward
computed results.</li></ul></li><li>other properties (mostly for backward compatibility)<ul><li><code>symbol</code>: the underlying symbolic graph for this module (if any)
This property is not necessarily constant. For example, for <code>BucketingModule</code>,
this property is simply the *current* symbol being used. For other modules,
this value might not be well defined.</li></ul></li></ul><p> When those intermediate-level API are implemented properly, the following
high-level API will be automatically available for a module:</p><ul><li><code>fit</code>: train the module parameters on a data set</li><li><code>predict</code>: run prediction on a data set and collect outputs</li><li><code>score</code>: run prediction on a data set and evaluate performance
</li></ul></div></div>
</li><li name="org.apache.mxnet.module.BucketingModule" visbl="pub" data-isabs="false" fullComment="no" group="Ungrouped">
<a id="BucketingModuleextendsBaseModule"></a>
<a id="BucketingModule:BucketingModule"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">class</span>
</span>
<span class="symbol">
<a href="BucketingModule.html"><span class="name">BucketingModule</span></a><span class="result"> extends <a href="BaseModule.html" class="extype" name="org.apache.mxnet.module.BaseModule">BaseModule</a></span>
</span>
</h4><span class="permalink">
<a href="../../../../index.html#org.apache.mxnet.module.package@BucketingModuleextendsBaseModule" title="Permalink" target="_top">
<img src="../../../../lib/permalink.png" />
</a>
</span>
<p class="shortcomment cmt">This module helps to deal efficiently with varying-length inputs.</p>
</li><li name="org.apache.mxnet.module.DataParallelExecutorGroup" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="DataParallelExecutorGroupextendsAnyRef"></a>
<a id="DataParallelExecutorGroup:DataParallelExecutorGroup"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">class</span>
</span>
<span class="symbol">
<a href="DataParallelExecutorGroup.html"><span class="name">DataParallelExecutorGroup</span></a><span class="result"> extends <span class="extype" name="scala.AnyRef">AnyRef</span></span>
</span>
</h4><span class="permalink">
<a href="../../../../index.html#org.apache.mxnet.module.package@DataParallelExecutorGroupextendsAnyRef" title="Permalink" target="_top">
<img src="../../../../lib/permalink.png" />
</a>
</span>
<p class="shortcomment cmt">DataParallelExecutorGroup is a group of executors that lives on a group of devices.</p><div class="fullcomment"><div class="comment cmt"><p>DataParallelExecutorGroup is a group of executors that lives on a group of devices.
This is a helper class used to implement data parallelism. Each mini-batch will
be split and run on the devices.</p></div></div>
</li><li name="org.apache.mxnet.module.FitParams" visbl="pub" data-isabs="false" fullComment="no" group="Ungrouped">
<a id="FitParamsextendsAnyRef"></a>
<a id="FitParams:FitParams"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">class</span>
</span>
<span class="symbol">
<a href="FitParams.html"><span class="name">FitParams</span></a><span class="result"> extends <span class="extype" name="scala.AnyRef">AnyRef</span></span>
</span>
</h4><span class="permalink">
<a href="../../../../index.html#org.apache.mxnet.module.package@FitParamsextendsAnyRef" title="Permalink" target="_top">
<img src="../../../../lib/permalink.png" />
</a>
</span>
</li><li name="org.apache.mxnet.module.Module" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="ModuleextendsBaseModule"></a>
<a id="Module:Module"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">class</span>
</span>
<span class="symbol">
<a href="Module.html"><span class="name">Module</span></a><span class="result"> extends <a href="BaseModule.html" class="extype" name="org.apache.mxnet.module.BaseModule">BaseModule</a></span>
</span>
</h4><span class="permalink">
<a href="../../../../index.html#org.apache.mxnet.module.package@ModuleextendsBaseModule" title="Permalink" target="_top">
<img src="../../../../lib/permalink.png" />
</a>
</span>
<p class="shortcomment cmt">Module is a basic module that wrap a <code>Symbol</code>.</p><div class="fullcomment"><div class="comment cmt"><p>Module is a basic module that wrap a <code>Symbol</code>. It is functionally the same
as the <code>FeedForward</code> model, except under the module API.</p></div></div>
</li><li name="org.apache.mxnet.module.SequentialModule" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="SequentialModuleextendsBaseModule"></a>
<a id="SequentialModule:SequentialModule"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">class</span>
</span>
<span class="symbol">
<a href="SequentialModule.html"><span class="name">SequentialModule</span></a><span class="result"> extends <a href="BaseModule.html" class="extype" name="org.apache.mxnet.module.BaseModule">BaseModule</a></span>
</span>
</h4><span class="permalink">
<a href="../../../../index.html#org.apache.mxnet.module.package@SequentialModuleextendsBaseModule" title="Permalink" target="_top">
<img src="../../../../lib/permalink.png" />
</a>
</span>
<p class="shortcomment cmt">A SequentialModule is a container module that can chain multiple modules together.</p><div class="fullcomment"><div class="comment cmt"><p>A SequentialModule is a container module that can chain multiple modules together.
Note building a computation graph with this kind of imperative container is less
flexible and less efficient than the symbolic graph.
So this should be only used as a handy utility.
</p></div></div>
</li></ol>
</div>
<div id="values" class="values members">
<h3>Value Members</h3>
<ol><li name="org.apache.mxnet.module.BaseModule" visbl="pub" data-isabs="false" fullComment="no" group="Ungrouped">
<a id="BaseModule"></a>
<a id="BaseModule:BaseModule"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">object</span>
</span>
<span class="symbol">
<a href="BaseModule$.html"><span class="name">BaseModule</span></a>
</span>
</h4><span class="permalink">
<a href="../../../../index.html#org.apache.mxnet.module.package@BaseModule" title="Permalink" target="_top">
<img src="../../../../lib/permalink.png" />
</a>
</span>
</li><li name="org.apache.mxnet.module.Module" visbl="pub" data-isabs="false" fullComment="no" group="Ungrouped">
<a id="Module"></a>
<a id="Module:Module"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">object</span>
</span>
<span class="symbol">
<a href="Module$.html"><span class="name">Module</span></a>
</span>
</h4><span class="permalink">
<a href="../../../../index.html#org.apache.mxnet.module.package@Module" title="Permalink" target="_top">
<img src="../../../../lib/permalink.png" />
</a>
</span>
</li></ol>
</div>
</div>
<div id="inheritedMembers">
</div>
<div id="groupedMembers">
<div class="group" name="Ungrouped">
<h3>Ungrouped</h3>
</div>
</div>
</div>
<div id="tooltip"></div>
<div id="footer"> </div>
</body>
</html>