This is an automated email from the ASF dual-hosted git repository. aaronmarkham pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/incubator-mxnet-site.git
The following commit(s) were added to refs/heads/asf-site by this push: new 67d931b8 Publish triggered by CI 67d931b8 is described below commit 67d931b8fa0c4f1268a7b05be31e297bf58e9c87 Author: mxnet-ci <mxnet-ci> AuthorDate: Fri Jul 17 12:41:49 2020 +0000 Publish triggered by CI --- api/python/docs/_modules/mxnet/gluon/block.html | 130 ++++++++++----------- .../docs/_modules/mxnet/gluon/parameter.html | 60 +++++----- api/python/docs/_modules/mxnet/util.html | 82 ++++++------- date.txt | 1 - feed.xml | 2 +- 5 files changed, 137 insertions(+), 138 deletions(-) diff --git a/api/python/docs/_modules/mxnet/gluon/block.html b/api/python/docs/_modules/mxnet/gluon/block.html index f0a44f2..0cdafac 100644 --- a/api/python/docs/_modules/mxnet/gluon/block.html +++ b/api/python/docs/_modules/mxnet/gluon/block.html @@ -965,7 +965,7 @@ <span class="k">return</span> <span class="n">_merger</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="n">fmt</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span> -<span class="k">class</span> <span class="nc">Block</span><span class="p">:</span> +<div class="viewcode-block" id="Block"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.Block">[docs]</a><span class="k">class</span> <span class="nc">Block</span><span class="p">:</span> <span class="sd">"""Base class for all neural network layers and models. Your models should</span> <span class="sd"> subclass this class.</span> @@ -1062,7 +1062,7 @@ <span class="sd"> children's parameters)."""</span> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_reg_params</span> - <span class="k">def</span> <span class="nf">collect_params</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">select</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> +<div class="viewcode-block" id="Block.collect_params"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.Block.collect_params">[docs]</a> <span class="k">def</span> <span class="nf">collect_params</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">select</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> <span class="sd">"""Returns a :py:class:`Dict` containing this :py:class:`Block` and all of its</span> <span class="sd"> children's Parameters(default), also can returns the select :py:class:`Dict`</span> <span class="sd"> which match some given regular expressions.</span> @@ -1088,7 +1088,7 @@ <span class="sd"> """</span> <span class="c1"># We need to check here because blocks inside containers are not supported.</span> <span class="bp">self</span><span class="o">.</span><span class="n">_check_container_with_block</span><span class="p">()</span> - <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_collect_params_with_prefix</span><span class="p">(</span><span class="n">select</span><span class="o">=</span><span class="n">select</span><span class="p">)</span> + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_collect_params_with_prefix</span><span class="p">(</span><span class="n">select</span><span class="o">=</span><span class="n">select</span><span class="p">)</span></div> <span class="k">def</span> <span class="nf">_collect_params_with_prefix</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s1">''</span><span class="p">,</span> <span class="n">select</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> <span class="k">if</span> <span class="n">prefix</span><span class="p">:</span> @@ -1103,7 +1103,7 @@ <span class="n">ret</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">child</span><span class="p">()</span><span class="o">.</span><span class="n">_collect_params_with_prefix</span><span class="p">(</span><span class="n">prefix</span> <span class="o">+</span> <span class="n">name</span><span class="p">,</span> <span class="n">select</span><span class="p">))</span> <span class="k">return</span> <span class="n">ret</span> - <span class="k">def</span> <span class="nf">save_parameters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">deduplicate</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> +<div class="viewcode-block" id="Block.save_parameters"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.Block.save_parameters">[docs]</a> <span class="k">def</span> <span class="nf">save_parameters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">deduplicate</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> <span class="sd">"""Save parameters to file.</span> <span class="sd"> Saved parameters can only be loaded with `load_parameters`. Note that this</span> @@ -1137,9 +1137,9 @@ <span class="n">arg_dict</span> <span class="o">=</span> <span class="p">{</span><span class="n">key</span><span class="p">:</span> <span class="n">val</span><span class="o">.</span><span class="n">_reduce</span><span class="p">()</span> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">val</span> <span class="ow">in</span> <span class="n">params</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span> <span class="n">save_fn</span> <span class="o">=</span> <span class="n">_mx_npx</span><span class="o">.</span><span class="n">save</span> <span class="k">if</span> <span class="n">is_np_array</span><span class="p">()</span> <span class="k">else</span> <span class="n">ndarray</span><span class="o">.</span><span class="n">save</span> - <span class="n">save_fn</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="n">arg_dict</span><span class="p">)</span> + <span class="n">save_fn</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="n">arg_dict</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">load_parameters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">ctx</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">allow_missing</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +<div class="viewcode-block" id="Block.load_parameters"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.Block.load_parameters">[docs]</a> <span class="k">def</span> <span class="nf">load_parameters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">ctx</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">all [...] <span class="n">ignore_extra</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">cast_dtype</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">dtype_source</span><span class="o">=</span><span class="s1">'current'</span><span class="p">):</span> <span class="sd">"""Load parameters from file previously saved by `save_parameters`.</span> @@ -1192,9 +1192,9 @@ <span class="k">if</span> <span class="ow">not</span> <span class="n">loaded</span><span class="p">:</span> <span class="k">return</span> <span class="n">full_dict</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'params'</span><span class="p">:</span> <span class="n">loaded</span><span class="p">,</span> <span class="s1">'filename'</span><span class="p">:</span> <span class="n">filename</span><span class="p">}</span> - <span class="bp">self</span><span class="o">.</span><span class="n">load_dict</span><span class="p">(</span><span class="n">full_dict</span><span class="p">,</span> <span class="n">ctx</span><span class="p">,</span> <span class="n">allow_missing</span><span class="p">,</span> <span class="n">ignore_extra</span><span class="p">,</span> <span class="n">cast_dtype</span><span class="p">,</span> <span class="n">dtype_source</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">load_dict</span><span class="p">(</span><span class="n">full_dict</span><span class="p">,</span> <span class="n">ctx</span><span class="p">,</span> <span class="n">allow_missing</span><span class="p">,</span> <span class="n">ignore_extra</span><span class="p">,</span> <span class="n">cast_dtype</span><span class="p">,</span> <span class="n">dtype_source</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">load_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">param_dict</span><span class="p">,</span> <span class="n">ctx</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">allow_missing</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +<div class="viewcode-block" id="Block.load_dict"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.Block.load_dict">[docs]</a> <span class="k">def</span> <span class="nf">load_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">param_dict</span><span class="p">,</span> <span class="n">ctx</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">allow_missing</span [...] <span class="n">ignore_extra</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">cast_dtype</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">dtype_source</span><span class="o">=</span><span class="s2">"current"</span><span class="p">):</span> <span class="sd">"""Load parameters from dict</span> @@ -1251,16 +1251,16 @@ <span class="n">param</span> <span class="o">=</span> <span class="n">loaded</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">):</span> <span class="n">param</span> <span class="o">=</span> <span class="n">_mx_np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">param</span><span class="p">)</span> <span class="k">if</span> <span class="n">is_np_array</span><span class="p">()</span> <span class="k">else</span> <span class="n">nd</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">param</span><span class="p">)</span> - <span class="n">params</span><span class="p">[</span><span class="n">name</span><span class="p">]</span><span class="o">.</span><span class="n">_load_init</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">ctx</span><span class="p">,</span> <span class="n">cast_dtype</span><span class="o">=</span><span class="n">cast_dtype</span><span class="p">,</span> <span class="n">dtype_source</span><span class="o">=</span><span class=" [...] + <span class="n">params</span><span class="p">[</span><span class="n">name</span><span class="p">]</span><span class="o">.</span><span class="n">_load_init</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">ctx</span><span class="p">,</span> <span class="n">cast_dtype</span><span class="o">=</span><span class="n">cast_dtype</span><span class="p">,</span> <span class="n">dtype_source</span><span class="o">=</span><span class=" [...] - <span class="k">def</span> <span class="nf">register_child</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">block</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> +<div class="viewcode-block" id="Block.register_child"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.Block.register_child">[docs]</a> <span class="k">def</span> <span class="nf">register_child</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">block</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> <span class="sd">"""Registers block as a child of self. :py:class:`Block` s assigned to self as</span> <span class="sd"> attributes will be registered automatically."""</span> <span class="k">if</span> <span class="n">name</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> <span class="n">name</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_children</span><span class="p">))</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_children</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">weakref</span><span class="o">.</span><span class="n">ref</span><span class="p">(</span><span class="n">block</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_children</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">weakref</span><span class="o">.</span><span class="n">ref</span><span class="p">(</span><span class="n">block</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">register_forward_pre_hook</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">hook</span><span class="p">):</span> +<div class="viewcode-block" id="Block.register_forward_pre_hook"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.Block.register_forward_pre_hook">[docs]</a> <span class="k">def</span> <span class="nf">register_forward_pre_hook</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">hook</span><span class="p">):</span> <span class="sa">r</span><span class="sd">"""Registers a forward pre-hook on the block.</span> <span class="sd"> The hook function is called immediately before :func:`forward`.</span> @@ -1277,9 +1277,9 @@ <span class="sd"> """</span> <span class="n">handle</span> <span class="o">=</span> <span class="n">HookHandle</span><span class="p">()</span> <span class="n">handle</span><span class="o">.</span><span class="n">attach</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_forward_pre_hooks</span><span class="p">,</span> <span class="n">hook</span><span class="p">)</span> - <span class="k">return</span> <span class="n">handle</span> + <span class="k">return</span> <span class="n">handle</span></div> - <span class="k">def</span> <span class="nf">register_forward_hook</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">hook</span><span class="p">):</span> +<div class="viewcode-block" id="Block.register_forward_hook"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.Block.register_forward_hook">[docs]</a> <span class="k">def</span> <span class="nf">register_forward_hook</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">hook</span><span class="p">):</span> <span class="sa">r</span><span class="sd">"""Registers a forward hook on the block.</span> <span class="sd"> The hook function is called immediately after :func:`forward`.</span> @@ -1296,9 +1296,9 @@ <span class="sd"> """</span> <span class="n">handle</span> <span class="o">=</span> <span class="n">HookHandle</span><span class="p">()</span> <span class="n">handle</span><span class="o">.</span><span class="n">attach</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_forward_hooks</span><span class="p">,</span> <span class="n">hook</span><span class="p">)</span> - <span class="k">return</span> <span class="n">handle</span> + <span class="k">return</span> <span class="n">handle</span></div> - <span class="k">def</span> <span class="nf">apply</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fn</span><span class="p">):</span> +<div class="viewcode-block" id="Block.apply"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.Block.apply">[docs]</a> <span class="k">def</span> <span class="nf">apply</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fn</span><span class="p">):</span> <span class="sa">r</span><span class="sd">"""Applies ``fn`` recursively to every child block as well as self.</span> <span class="sd"> Parameters</span> @@ -1313,9 +1313,9 @@ <span class="k">for</span> <span class="n">cld</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_children</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> <span class="n">cld</span><span class="p">()</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span><span class="n">fn</span><span class="p">)</span> <span class="n">fn</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> - <span class="k">return</span> <span class="bp">self</span> + <span class="k">return</span> <span class="bp">self</span></div> - <span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">init</span><span class="o">=</span><span class="n">initializer</span><span class="o">.</span><span class="n">Uniform</span><span class="p">(),</span> <span class="n">ctx</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">verbose</span><span class="o">=</span><span class="kc">False</spa [...] +<div class="viewcode-block" id="Block.initialize"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.Block.initialize">[docs]</a> <span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">init</span><span class="o">=</span><span class="n">initializer</span><span class="o">.</span><span class="n">Uniform</span><span class="p">(),</span> <span class="n">ctx</span>< [...] <span class="n">force_reinit</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> <span class="sd">"""Initializes :py:class:`Parameter` s of this :py:class:`Block` and its children.</span> @@ -1335,15 +1335,15 @@ <span class="k">if</span> <span class="n">verbose</span><span class="p">:</span> <span class="n">init</span><span class="o">.</span><span class="n">set_verbosity</span><span class="p">(</span><span class="n">verbose</span><span class="o">=</span><span class="n">verbose</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">params</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> - <span class="n">v</span><span class="o">.</span><span class="n">initialize</span><span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="n">ctx</span><span class="p">,</span> <span class="n">init</span><span class="p">,</span> <span class="n">force_reinit</span><span class="o">=</span><span class="n">force_reinit</span><span class="p">)</span> + <span class="n">v</span><span class="o">.</span><span class="n">initialize</span><span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="n">ctx</span><span class="p">,</span> <span class="n">init</span><span class="p">,</span> <span class="n">force_reinit</span><span class="o">=</span><span class="n">force_reinit</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">hybridize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">active</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> +<div class="viewcode-block" id="Block.hybridize"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.Block.hybridize">[docs]</a> <span class="k">def</span> <span class="nf">hybridize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">active</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> <span class="sd">""" Please refer description of HybridBlock hybridize().</span> <span class="sd"> """</span> <span class="k">for</span> <span class="n">cld</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_children</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> - <span class="n">cld</span><span class="p">()</span><span class="o">.</span><span class="n">hybridize</span><span class="p">(</span><span class="n">active</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> + <span class="n">cld</span><span class="p">()</span><span class="o">.</span><span class="n">hybridize</span><span class="p">(</span><span class="n">active</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">cast</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dtype</span><span class="p">):</span> +<div class="viewcode-block" id="Block.cast"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.Block.cast">[docs]</a> <span class="k">def</span> <span class="nf">cast</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dtype</span><span class="p">):</span> <span class="sd">"""Cast this Block to use another data type.</span> <span class="sd"> Parameters</span> @@ -1354,9 +1354,9 @@ <span class="k">for</span> <span class="n">child</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_children</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> <span class="n">child</span><span class="p">()</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span> <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">param</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> - <span class="n">param</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span> + <span class="n">param</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">zero_grad</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +<div class="viewcode-block" id="Block.zero_grad"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.Block.zero_grad">[docs]</a> <span class="k">def</span> <span class="nf">zero_grad</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""Sets all Parameters' gradient buffer to 0."""</span> <span class="c1"># collect gradient arrays for each ctx</span> <span class="n">arrays</span> <span class="o">=</span> <span class="n">defaultdict</span><span class="p">(</span><span class="nb">list</span><span class="p">)</span> @@ -1379,9 +1379,9 @@ <span class="n">ele</span><span class="p">[()]</span> <span class="o">=</span> <span class="mi">0</span> <span class="k">else</span><span class="p">:</span> <span class="k">for</span> <span class="n">arr</span> <span class="ow">in</span> <span class="n">arrays</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> - <span class="n">ndarray</span><span class="o">.</span><span class="n">reset_arrays</span><span class="p">(</span><span class="o">*</span><span class="n">arr</span><span class="p">,</span> <span class="n">num_arrays</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">arr</span><span class="p">))</span> + <span class="n">ndarray</span><span class="o">.</span><span class="n">reset_arrays</span><span class="p">(</span><span class="o">*</span><span class="n">arr</span><span class="p">,</span> <span class="n">num_arrays</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">arr</span><span class="p">))</span></div> - <span class="k">def</span> <span class="nf">reset_ctx</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="p">):</span> +<div class="viewcode-block" id="Block.reset_ctx"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.Block.reset_ctx">[docs]</a> <span class="k">def</span> <span class="nf">reset_ctx</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="p">):</span> <span class="sd">"""Re-assign all Parameters to other contexts.</span> <span class="sd"> Parameters</span> @@ -1392,9 +1392,9 @@ <span class="sd"> """</span> <span class="n">params</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">collect_params</span><span class="p">()</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">params</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> - <span class="n">i</span><span class="o">.</span><span class="n">reset_ctx</span><span class="p">(</span><span class="n">ctx</span><span class="p">)</span> + <span class="n">i</span><span class="o">.</span><span class="n">reset_ctx</span><span class="p">(</span><span class="n">ctx</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span> +<div class="viewcode-block" id="Block.setattr"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.Block.setattr">[docs]</a> <span class="k">def</span> <span class="nf">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span> <span class="sd">"""Set an attribute to a new value for all Parameters.</span> <span class="sd"> For example, set grad_req to null if you don't need gradient w.r.t a</span> @@ -1415,9 +1415,9 @@ <span class="sd"> """</span> <span class="n">params</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">collect_params</span><span class="p">()</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">params</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> - <span class="nb">setattr</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span> + <span class="nb">setattr</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">share_parameters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">shared</span><span class="p">):</span> +<div class="viewcode-block" id="Block.share_parameters"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.Block.share_parameters">[docs]</a> <span class="k">def</span> <span class="nf">share_parameters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">shared</span><span class="p">):</span> <span class="sd">"""Share parameters recursively inside the model.</span> <span class="sd"> For example, if you want ``dense1`` to share ``dense0``'s weights, you can do::</span> @@ -1456,7 +1456,7 @@ <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">shared_set</span><span class="p">)</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">shared_set</span><span class="p">:</span> <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">"Parameter name </span><span class="si">{}</span><span class="s2"> is not in the current model!"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="p">))</span> - <span class="k">return</span> <span class="bp">self</span> + <span class="k">return</span> <span class="bp">self</span></div> <span class="k">def</span> <span class="nf">_shared_parameters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">shared</span><span class="p">,</span> <span class="n">shared_set</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">""</span><span class="p">):</span> <span class="k">if</span> <span class="n">prefix</span><span class="p">:</span> @@ -1482,7 +1482,7 @@ <span class="n">_check_all_np_ndarrays</span><span class="p">(</span><span class="n">out</span><span class="p">)</span> <span class="k">return</span> <span class="n">out</span> - <span class="k">def</span> <span class="nf">forward</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span> +<div class="viewcode-block" id="Block.forward"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.Block.forward">[docs]</a> <span class="k">def</span> <span class="nf">forward</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span> <span class="sd">"""Overrides to implement forward computation using :py:class:`NDArray`. Only</span> <span class="sd"> accepts positional arguments.</span> @@ -1492,9 +1492,9 @@ <span class="sd"> Input tensors.</span> <span class="sd"> """</span> <span class="c1"># pylint: disable= invalid-name</span> - <span class="k">raise</span> <span class="ne">NotImplementedError</span> + <span class="k">raise</span> <span class="ne">NotImplementedError</span></div> - <span class="k">def</span> <span class="nf">register_op_hook</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">callback</span><span class="p">,</span> <span class="n">monitor_all</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> +<div class="viewcode-block" id="Block.register_op_hook"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.Block.register_op_hook">[docs]</a> <span class="k">def</span> <span class="nf">register_op_hook</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">callback</span><span class="p">,</span> <span class="n">monitor_all</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> <span class="sd">"""Install callback monitor.</span> <span class="sd"> Parameters</span> @@ -1509,9 +1509,9 @@ <span class="sd"> If True, monitor both input and output, otherwise monitor output only.</span> <span class="sd"> """</span> <span class="k">for</span> <span class="n">cld</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_children</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> - <span class="n">cld</span><span class="p">()</span><span class="o">.</span><span class="n">register_op_hook</span><span class="p">(</span><span class="n">callback</span><span class="p">,</span> <span class="n">monitor_all</span><span class="p">)</span> + <span class="n">cld</span><span class="p">()</span><span class="o">.</span><span class="n">register_op_hook</span><span class="p">(</span><span class="n">callback</span><span class="p">,</span> <span class="n">monitor_all</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">summary</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">inputs</span><span class="p">):</span> +<div class="viewcode-block" id="Block.summary"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.Block.summary">[docs]</a> <span class="k">def</span> <span class="nf">summary</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">inputs</span><span class="p">):</span> <span class="sd">"""Print the summary of the model's output and parameters.</span> <span class="sd"> The network must have been initialized, and must not have been hybridized.</span> @@ -1620,10 +1620,10 @@ <span class="nb">print</span><span class="p">(</span><span class="s1">'-'</span><span class="o">*</span><span class="mi">80</span><span class="p">)</span> <span class="k">finally</span><span class="p">:</span> <span class="k">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">hooks</span><span class="p">:</span> - <span class="n">h</span><span class="o">.</span><span class="n">detach</span><span class="p">()</span> + <span class="n">h</span><span class="o">.</span><span class="n">detach</span><span class="p">()</span></div></div> -<span class="k">class</span> <span class="nc">HybridBlock</span><span class="p">(</span><span class="n">Block</span><span class="p">):</span> +<div class="viewcode-block" id="HybridBlock"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.HybridBlock">[docs]</a><span class="k">class</span> <span class="nc">HybridBlock</span><span class="p">(</span><span class="n">Block</span><span class="p">):</span> <span class="sd">"""`HybridBlock` supports forwarding with both Symbol and NDArray.</span> <span class="sd"> `HybridBlock` is similar to `Block`, with a few differences::</span> @@ -1899,7 +1899,7 @@ <span class="n">out</span> <span class="o">=</span> <span class="p">[</span><span class="n">out</span><span class="p">]</span> <span class="k">return</span> <span class="n">_regroup</span><span class="p">(</span><span class="n">out</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_out_format</span><span class="p">)</span> - <span class="k">def</span> <span class="nf">optimize_for</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="n">backend</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">backend_opts</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <spa [...] +<div class="viewcode-block" id="HybridBlock.optimize_for"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.HybridBlock.optimize_for">[docs]</a> <span class="k">def</span> <span class="nf">optimize_for</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="n">backend</span><span class="o">=</s [...] <span class="sd">"""Partitions the current HybridBlock and optimizes it for a given backend</span> <span class="sd"> without executing a forward pass. Modifies the HybridBlock in-place.</span> @@ -1959,14 +1959,14 @@ <span class="k">assert</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cached_op</span><span class="p">,</span> <span class="s2">"Gluon failed to build the cache. "</span> \ <span class="s2">"This should never happen. "</span> \ <span class="s2">"Please submit an issue on Github"</span> \ - <span class="s2">" https://github.com/apache/incubator-mxnet."</span> + <span class="s2">" https://github.com/apache/incubator-mxnet."</span></div> <span class="c1"># do not actually call the cached_op</span> <span class="k">def</span> <span class="nf">_clear_cached_op</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cached_graph</span> <span class="o">=</span> <span class="p">()</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cached_op</span> <span class="o">=</span> <span class="kc">None</span> - <span class="k">def</span> <span class="nf">register_child</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">block</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> +<div class="viewcode-block" id="HybridBlock.register_child"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.HybridBlock.register_child">[docs]</a> <span class="k">def</span> <span class="nf">register_child</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">block</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">block</span><span class="p">,</span> <span class="n">HybridBlock</span><span class="p">):</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span> <span class="s2">"Children of HybridBlock must also be HybridBlock, "</span> \ @@ -1978,9 +1978,9 @@ <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">"Currently the model has been hybridized. Automatically deactivate the hybridization </span><span class="se">\</span> <span class="s2"> when adding new children block."</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">_active</span> <span class="o">=</span> <span class="kc">False</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_clear_cached_op</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_clear_cached_op</span><span class="p">()</span></div> - <span class="k">def</span> <span class="nf">hybridize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">active</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">backend</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">backend_opts</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span>< [...] +<div class="viewcode-block" id="HybridBlock.hybridize"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.HybridBlock.hybridize">[docs]</a> <span class="k">def</span> <span class="nf">hybridize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">active</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">backend</span><span class="o">=</span><span class="kc">None</s [...] <span class="sd">"""Activates or deactivates :py:class:`HybridBlock` s recursively. Has no effect on</span> <span class="sd"> non-hybrid children.</span> @@ -2013,15 +2013,15 @@ <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s1">'"</span><span class="si">{block}</span><span class="s1">" is being hybridized while still having forward hook/pre-hook. '</span> <span class="s1">'If "</span><span class="si">{block}</span><span class="s1">" is a child of HybridBlock, the hooks will not take effect.'</span> <span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">block</span><span class="o">=</span><span class="bp">self</span><span class="p">))</span> - <span class="nb">super</span><span class="p">(</span><span class="n">HybridBlock</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">hybridize</span><span class="p">(</span><span class="n">active</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> + <span class="nb">super</span><span class="p">(</span><span class="n">HybridBlock</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">hybridize</span><span class="p">(</span><span class="n">active</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">cast</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dtype</span><span class="p">):</span> +<div class="viewcode-block" id="HybridBlock.cast"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.HybridBlock.cast">[docs]</a> <span class="k">def</span> <span class="nf">cast</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dtype</span><span class="p">):</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_active</span><span class="p">:</span> <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">"Currently the model has been hybridized. Automatically deactivate the hybridization </span><span class="se">\</span> <span class="s2"> when cast the block to use another data type."</span><span class="p">)</span> <span class="bp">self</span><span class="o">.</span><span class="n">_active</span> <span class="o">=</span> <span class="kc">False</span> <span class="bp">self</span><span class="o">.</span><span class="n">_clear_cached_op</span><span class="p">()</span> - <span class="nb">super</span><span class="p">(</span><span class="n">HybridBlock</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span> + <span class="nb">super</span><span class="p">(</span><span class="n">HybridBlock</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span></div> <span class="k">def</span> <span class="nf">_infer_attrs</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">infer_fn</span><span class="p">,</span> <span class="n">attr</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span> <span class="sd">"""Generic infer attributes."""</span> @@ -2039,7 +2039,7 @@ <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">collect_params</span><span class="p">()</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> <span class="nb">setattr</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">attr</span><span class="p">,</span> <span class="n">sdict</span><span class="p">[</span><span class="n">i</span><span class="o">.</span><span class="n">var</span><span class="p">()</span><span class="o">.</span><span class="n">name</span><span class="p">])</span> - <span class="k">def</span> <span class="nf">infer_shape</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span> +<div class="viewcode-block" id="HybridBlock.infer_shape"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.HybridBlock.infer_shape">[docs]</a> <span class="k">def</span> <span class="nf">infer_shape</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span> <span class="sd">"""Infers shape of Parameters from inputs."""</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">hybrid_forward</span><span class="o">.</span><span class="vm">__func__</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">HybridBlock</span><span class="o">.</span><span class="n">hybrid_forward</span><span class="p">:</span> <span class="c1"># Gluon 1 based on F: hybrid_forward is defined by user</span> @@ -2054,13 +2054,13 @@ <span class="s2">"</span><span class="si">{name}</span><span class="s2"> has parameters with unknown shape. You need to either specify the shape "</span> <span class="s2">"in __init__ or implement </span><span class="si">{name}</span><span class="s2">.infer_shape to set the parameter shapes "</span> <span class="s2">"based on the first input. Parameters with unknown shapes are </span><span class="si">{params}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span> - <span class="n">name</span><span class="o">=</span><span class="nb">type</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span> <span class="n">params</span><span class="o">=</span><span class="n">params_str</span><span class="p">))</span> + <span class="n">name</span><span class="o">=</span><span class="nb">type</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span> <span class="n">params</span><span class="o">=</span><span class="n">params_str</span><span class="p">))</span></div> - <span class="k">def</span> <span class="nf">infer_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span> +<div class="viewcode-block" id="HybridBlock.infer_type"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.HybridBlock.infer_type">[docs]</a> <span class="k">def</span> <span class="nf">infer_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span> <span class="sd">"""Infers data type of Parameters from inputs."""</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_infer_attrs</span><span class="p">(</span><span class="s1">'infer_type'</span><span class="p">,</span> <span class="s1">'dtype'</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_infer_attrs</span><span class="p">(</span><span class="s1">'infer_type'</span><span class="p">,</span> <span class="s1">'dtype'</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">export</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="n">epoch</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">remove_amp_cast</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> +<div class="viewcode-block" id="HybridBlock.export"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.HybridBlock.export">[docs]</a> <span class="k">def</span> <span class="nf">export</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="n">epoch</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">remove_amp_cast</span>< [...] <span class="sd">"""Export HybridBlock to json format that can be loaded by</span> <span class="sd"> `gluon.SymbolBlock.imports` or the C++ interface.</span> @@ -2117,9 +2117,9 @@ <span class="n">save_fn</span> <span class="o">=</span> <span class="n">_mx_npx</span><span class="o">.</span><span class="n">save</span> <span class="k">if</span> <span class="n">is_np_array</span><span class="p">()</span> <span class="k">else</span> <span class="n">ndarray</span><span class="o">.</span><span class="n">save</span> <span class="n">params_filename</span> <span class="o">=</span> <span class="s1">'</span><span class="si">%s</span><span class="s1">-</span><span class="si">%04d</span><span class="s1">.params'</span><span class="o">%</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">epoch</span><span class="p">)</span> <span class="n">save_fn</span><span class="p">(</span><span class="n">params_filename</span><span class="p">,</span> <span class="n">arg_dict</span><span class="p">)</span> - <span class="k">return</span> <span class="p">(</span><span class="n">sym_filename</span><span class="p">,</span> <span class="n">params_filename</span><span class="p">)</span> + <span class="k">return</span> <span class="p">(</span><span class="n">sym_filename</span><span class="p">,</span> <span class="n">params_filename</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">register_op_hook</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">callback</span><span class="p">,</span> <span class="n">monitor_all</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> +<div class="viewcode-block" id="HybridBlock.register_op_hook"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.HybridBlock.register_op_hook">[docs]</a> <span class="k">def</span> <span class="nf">register_op_hook</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">callback</span><span class="p">,</span> <span class="n">monitor_all</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> <span class="sd">"""Install op hook for block recursively.</span> <span class="sd"> Parameters</span> @@ -2146,7 +2146,7 @@ <span class="bp">self</span><span class="o">.</span><span class="n">_monitor_all</span> <span class="o">=</span> <span class="n">monitor_all</span> <span class="k">for</span> <span class="n">cld</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_children</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> <span class="n">cld</span><span class="p">()</span><span class="o">.</span><span class="n">_callback</span> <span class="o">=</span> <span class="n">c_callback</span> - <span class="n">cld</span><span class="p">()</span><span class="o">.</span><span class="n">_monitor_all</span> <span class="o">=</span> <span class="n">monitor_all</span> + <span class="n">cld</span><span class="p">()</span><span class="o">.</span><span class="n">_monitor_all</span> <span class="o">=</span> <span class="n">monitor_all</span></div> <span class="k">def</span> <span class="fm">__call__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">hybrid_forward</span><span class="o">.</span><span class="vm">__func__</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">HybridBlock</span><span class="o">.</span><span class="n">hybrid_forward</span><span class="p">:</span> @@ -2174,7 +2174,7 @@ <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_call_cached_op</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> - <span class="k">def</span> <span class="nf">forward</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span> +<div class="viewcode-block" id="HybridBlock.forward"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.HybridBlock.forward">[docs]</a> <span class="k">def</span> <span class="nf">forward</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span> <span class="sd">"""Defines the forward computation. Arguments can be either</span> <span class="sd"> :py:class:`NDArray` or :py:class:`Symbol`."""</span> @@ -2210,9 +2210,9 @@ <span class="n">params</span> <span class="o">=</span> <span class="p">{</span><span class="n">i</span><span class="p">:</span> <span class="n">j</span><span class="o">.</span><span class="n">var</span><span class="p">()</span> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_reg_params</span><span class="o">.</span><span class="n">it [...] <span class="k">with</span> <span class="n">_block_scope</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> - <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">hybrid_forward</span><span class="p">(</span><span class="n">symbol</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">params</span><span class="p">)</span> + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">hybrid_forward</span><span class="p">(</span><span class="n">symbol</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">params</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">hybrid_forward</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">F</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> +<div class="viewcode-block" id="HybridBlock.hybrid_forward"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.HybridBlock.hybrid_forward">[docs]</a> <span class="k">def</span> <span class="nf">hybrid_forward</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">F</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</s [...] <span class="sd">"""Overrides to construct symbolic graph for this `Block`.</span> <span class="sd"> Parameters</span> @@ -2223,9 +2223,9 @@ <span class="sd"> Additional input tensors.</span> <span class="sd"> """</span> <span class="c1"># pylint: disable= invalid-name</span> - <span class="k">raise</span> <span class="ne">NotImplementedError</span> + <span class="k">raise</span> <span class="ne">NotImplementedError</span></div> - <span class="k">def</span> <span class="nf">reset_ctx</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="p">):</span> +<div class="viewcode-block" id="HybridBlock.reset_ctx"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.HybridBlock.reset_ctx">[docs]</a> <span class="k">def</span> <span class="nf">reset_ctx</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="p">):</span> <span class="sd">"""Re-assign all Parameters to other contexts. If the Block is hybridized, it will reset the _cached_op_args.</span> <span class="sd"> Parameters</span> @@ -2241,9 +2241,9 @@ <span class="k">if</span> <span class="n">p</span><span class="o">.</span><span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">params</span><span class="p">:</span> <span class="n">p</span><span class="o">.</span><span class="n">reset_ctx</span><span class="p">(</span><span class="n">ctx</span><span class="p">)</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">params</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> - <span class="n">p</span><span class="o">.</span><span class="n">reset_ctx</span><span class="p">(</span><span class="n">ctx</span><span class="p">)</span> + <span class="n">p</span><span class="o">.</span><span class="n">reset_ctx</span><span class="p">(</span><span class="n">ctx</span><span class="p">)</span></div></div> -<div class="viewcode-block" id="SymbolBlock"><a class="viewcode-back" href="../../../api/gluon/symbol_block.html#mxnet.gluon.SymbolBlock">[docs]</a><span class="k">class</span> <span class="nc">SymbolBlock</span><span class="p">(</span><span class="n">HybridBlock</span><span class="p">):</span> +<div class="viewcode-block" id="SymbolBlock"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.SymbolBlock">[docs]</a><span class="k">class</span> <span class="nc">SymbolBlock</span><span class="p">(</span><span class="n">HybridBlock</span><span class="p">):</span> <span class="sd">"""Construct block from symbol. This is useful for using pre-trained models</span> <span class="sd"> as feature extractors. For example, you may want to extract the output</span> <span class="sd"> from fc2 layer in AlexNet.</span> @@ -2274,7 +2274,7 @@ <span class="sd"> >>> x = mx.nd.random.normal(shape=(16, 3, 224, 224))</span> <span class="sd"> >>> print(feat_model(x))</span> <span class="sd"> """</span> -<div class="viewcode-block" id="SymbolBlock.imports"><a class="viewcode-back" href="../../../api/gluon/symbol_block.html#mxnet.gluon.SymbolBlock.imports">[docs]</a> <span class="nd">@staticmethod</span> +<div class="viewcode-block" id="SymbolBlock.imports"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.SymbolBlock.imports">[docs]</a> <span class="nd">@staticmethod</span> <span class="k">def</span> <span class="nf">imports</span><span class="p">(</span><span class="n">symbol_file</span><span class="p">,</span> <span class="n">input_names</span><span class="p">,</span> <span class="n">param_file</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">ctx</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> <span class="sd">"""Import model previously saved by `gluon.HybridBlock.export`</span> <span class="sd"> as a `gluon.SymbolBlock` for use in Gluon.</span> @@ -2397,7 +2397,7 @@ <span class="bp">self</span><span class="o">.</span><span class="n">_cached_graph</span> <span class="o">=</span> <span class="n">syms</span><span class="p">,</span> <span class="n">out</span> -<div class="viewcode-block" id="SymbolBlock.forward"><a class="viewcode-back" href="../../../api/gluon/symbol_block.html#mxnet.gluon.SymbolBlock.forward">[docs]</a> <span class="k">def</span> <span class="nf">forward</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span> +<div class="viewcode-block" id="SymbolBlock.forward"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.SymbolBlock.forward">[docs]</a> <span class="k">def</span> <span class="nf">forward</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span> <span class="k">if</span> <span class="n">dc</span><span class="o">.</span><span class="n">is_deferred_compute</span><span class="p">():</span> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s1">'Calling a SymbolBlock from within HybridBlock '</span> <span class="s1">'is not yet supported in Gluon 2.'</span><span class="p">)</span> @@ -2420,7 +2420,7 @@ <span class="nb">super</span><span class="p">(</span><span class="n">SymbolBlock</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">_clear_cached_op</span><span class="p">()</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cached_graph</span> <span class="o">=</span> <span class="n">tmp</span> -<div class="viewcode-block" id="SymbolBlock.cast"><a class="viewcode-back" href="../../../api/gluon/symbol_block.html#mxnet.gluon.SymbolBlock.cast">[docs]</a> <span class="k">def</span> <span class="nf">cast</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dtype</span><span class="p">):</span> +<div class="viewcode-block" id="SymbolBlock.cast"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.SymbolBlock.cast">[docs]</a> <span class="k">def</span> <span class="nf">cast</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dtype</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">_clear_cached_op</span><span class="p">()</span> <span class="nb">super</span><span class="p">(</span><span class="n">SymbolBlock</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span> <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">dtype</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span><span class="o">.</span><span class="n">name</span> <span class="o">==</span> <span class="s1">'float16'</span><span class="p">:</span> @@ -2446,7 +2446,7 @@ <span class="k">for</span> <span class="n">sib</span> <span class="ow">in</span> <span class="n">sibs</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">sib</span><span class="p">)</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="s1">'float32'</span><span class="p">)</span></div> -<div class="viewcode-block" id="SymbolBlock.hybrid_forward"><a class="viewcode-back" href="../../../api/gluon/symbol_block.html#mxnet.gluon.SymbolBlock.hybrid_forward">[docs]</a> <span class="k">def</span> <span class="nf">hybrid_forward</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">F</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</ [...] +<div class="viewcode-block" id="SymbolBlock.hybrid_forward"><a class="viewcode-back" href="../../../api/gluon/nn/index.html#mxnet.gluon.nn.SymbolBlock.hybrid_forward">[docs]</a> <span class="k">def</span> <span class="nf">hybrid_forward</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">F</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</s [...] <span class="k">raise</span> <span class="ne">NotImplementedError</span></div></div> <span class="k">def</span> <span class="nf">_infer_param_types</span><span class="p">(</span><span class="n">in_params</span><span class="p">,</span> <span class="n">out_params</span><span class="p">,</span> <span class="n">arg_params</span><span class="p">,</span> <span class="n">aux_params</span><span class="p">,</span> <span class="n">default_dtype</span><span class="o">=</span><span class="n">mx_real_t</span><span class="p">):</span> diff --git a/api/python/docs/_modules/mxnet/gluon/parameter.html b/api/python/docs/_modules/mxnet/gluon/parameter.html index 909db62..c6541e5 100644 --- a/api/python/docs/_modules/mxnet/gluon/parameter.html +++ b/api/python/docs/_modules/mxnet/gluon/parameter.html @@ -811,7 +811,7 @@ <span class="sd">"""Error for unfinished deferred initialization."""</span> <span class="k">pass</span> -<span class="k">class</span> <span class="nc">Parameter</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> +<div class="viewcode-block" id="Parameter"><a class="viewcode-back" href="../../../api/gluon/parameter.html#mxnet.gluon.Parameter">[docs]</a><span class="k">class</span> <span class="nc">Parameter</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> <span class="sd">"""A Container holding parameters (weights) of Blocks.</span> <span class="sd"> :py:class:`Parameter` holds a copy of the parameter on each :py:class:`Context` after</span> @@ -1182,7 +1182,7 @@ <span class="n">trainer</span><span class="o">.</span><span class="n">_row_sparse_pull</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">all_row_ids</span><span class="p">,</span> <span class="n">full_idx</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="k">return</span> <span class="n">data</span> - <span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">init</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">ctx</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">default_init</span><span class="o">=</span><span class="n">initializer</span><span class="o">.</span><span class="n">Uniform</s [...] +<div class="viewcode-block" id="Parameter.initialize"><a class="viewcode-back" href="../../../api/gluon/parameter.html#mxnet.gluon.Parameter.initialize">[docs]</a> <span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">init</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">ctx</span><span class="o">=</span><span class="kc">None</span><span [...] <span class="n">force_reinit</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> <span class="sd">"""Initializes parameter and gradient arrays. Only used for :py:class:`NDArray` API.</span> @@ -1246,9 +1246,9 @@ <span class="s2">"invalid shape: </span><span class="si">%s</span><span class="s2">."</span><span class="o">%</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">shape</span><span class="p">)))</span> <span class="bp">self</span><span class="o">.</span><span class="n">_deferred_init</span> <span class="o">=</span> <span class="p">(</span><span class="n">init</span><span class="p">,</span> <span class="n">ctx</span><span class="p">,</span> <span class="n">default_init</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> - <span class="bp">self</span><span class="o">.</span><span class="n">_finish_deferred_init</span><span class="p">()</span> + <span class="bp">self</span><span class="o">.</span><span class="n">_finish_deferred_init</span><span class="p">()</span></div> - <span class="k">def</span> <span class="nf">reset_ctx</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="p">):</span> +<div class="viewcode-block" id="Parameter.reset_ctx"><a class="viewcode-back" href="../../../api/gluon/parameter.html#mxnet.gluon.Parameter.reset_ctx">[docs]</a> <span class="k">def</span> <span class="nf">reset_ctx</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="p">):</span> <span class="sd">"""Re-assign Parameter to other contexts.</span> <span class="sd"> Parameters</span> @@ -1270,9 +1270,9 @@ <span class="bp">self</span><span class="o">.</span><span class="n">_deferred_init</span> <span class="o">=</span> <span class="p">(</span><span class="n">init</span><span class="p">,</span> <span class="n">ctx</span><span class="p">,</span> <span class="n">default_init</span><span class="p">,</span> <span class="n">data</span><span class="p">)</span> <span class="k">else</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Cannot reset context for Parameter '</span><span class="si">%s</span><span class="s2">' because it "</span> - <span class="s2">"has not been initialized."</span><span class="o">%</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> + <span class="s2">"has not been initialized."</span><span class="o">%</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">set_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span> +<div class="viewcode-block" id="Parameter.set_data"><a class="viewcode-back" href="../../../api/gluon/parameter.html#mxnet.gluon.Parameter.set_data">[docs]</a> <span class="k">def</span> <span class="nf">set_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span> <span class="sd">"""Sets this parameter's value on all contexts."""</span> <span class="bp">self</span><span class="o">.</span><span class="n">shape</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">shape</span> @@ -1289,9 +1289,9 @@ <span class="n">trainer</span><span class="o">.</span><span class="n">_reset_kvstore</span><span class="p">()</span> <span class="k">for</span> <span class="n">arr</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_check_and_get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> - <span class="n">arr</span><span class="p">[:]</span> <span class="o">=</span> <span class="n">data</span> + <span class="n">arr</span><span class="p">[:]</span> <span class="o">=</span> <span class="n">data</span></div> - <span class="k">def</span> <span class="nf">row_sparse_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">row_id</span><span class="p">):</span> +<div class="viewcode-block" id="Parameter.row_sparse_data"><a class="viewcode-back" href="../../../api/gluon/parameter.html#mxnet.gluon.Parameter.row_sparse_data">[docs]</a> <span class="k">def</span> <span class="nf">row_sparse_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">row_id</span><span class="p">):</span> <span class="sd">"""Returns a copy of the 'row_sparse' parameter on the same context as row_id's.</span> <span class="sd"> The copy only retains rows whose ids occur in provided row ids.</span> <span class="sd"> The parameter must have been initialized on this context before.</span> @@ -1309,9 +1309,9 @@ <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"Cannot return a copy of Parameter </span><span class="si">%s</span><span class="s2"> via row_sparse_data() "</span> \ <span class="s2">"because its storage type is </span><span class="si">%s</span><span class="s2">. Please use data() instead."</span> \ <span class="o">%</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_stype</span><span class="p">))</span> - <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_row_sparse</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">,</span> <span class="n">row_id</span><span class="o">.</span><span class="n">ctx</span><span class="p">,</span> <span class="n">row_id</span><span class="p">)</span> + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_row_sparse</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">,</span> <span class="n">row_id</span><span class="o">.</span><span class="n">ctx</span><span class="p">,</span> <span class="n">row_id</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">list_row_sparse_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">row_id</span><span class="p">):</span> +<div class="viewcode-block" id="Parameter.list_row_sparse_data"><a class="viewcode-back" href="../../../api/gluon/parameter.html#mxnet.gluon.Parameter.list_row_sparse_data">[docs]</a> <span class="k">def</span> <span class="nf">list_row_sparse_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">row_id</span><span class="p">):</span> <span class="sd">"""Returns copies of the 'row_sparse' parameter on all contexts, in the same order</span> <span class="sd"> as creation. The copy only retains rows whose ids occur in provided row ids.</span> <span class="sd"> The parameter must have been initialized before.</span> @@ -1329,9 +1329,9 @@ <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"Cannot return copies of Parameter '</span><span class="si">%s</span><span class="s2">' on all contexts via "</span> \ <span class="s2">"list_row_sparse_data() because its storage type is </span><span class="si">%s</span><span class="s2">. Please "</span> \ <span class="s2">"use data() instead."</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_stype</span><span class="p">))</span> - <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_row_sparse</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">,</span> <span class="nb">list</span><span class="p">,</span> <span class="n">row_id</span><span class="p">)</span> + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_row_sparse</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">,</span> <span class="nb">list</span><span class="p">,</span> <span class="n">row_id</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> +<div class="viewcode-block" id="Parameter.data"><a class="viewcode-back" href="../../../api/gluon/parameter.html#mxnet.gluon.Parameter.data">[docs]</a> <span class="k">def</span> <span class="nf">data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> <span class="sd">"""Returns a copy of this parameter on one context. Must have been</span> <span class="sd"> initialized on this context before. For sparse parameters, use</span> <span class="sd"> :py:meth:`Parameter.row_sparse_data` instead.</span> @@ -1351,9 +1351,9 @@ <span class="s2">"instead."</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">ctx</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">_stype</span><span class="p">))</span> <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_check_and_get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">,</span> <span class="n">ctx</span><span class="p">)</span> <span class="n">dc</span><span class="o">.</span><span class="n">set_variable</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">var</span><span class="p">())</span> - <span class="k">return</span> <span class="n">data</span> + <span class="k">return</span> <span class="n">data</span></div> - <span class="k">def</span> <span class="nf">list_data</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +<div class="viewcode-block" id="Parameter.list_data"><a class="viewcode-back" href="../../../api/gluon/parameter.html#mxnet.gluon.Parameter.list_data">[docs]</a> <span class="k">def</span> <span class="nf">list_data</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""Returns copies of this parameter on all contexts, in the same order</span> <span class="sd"> as creation. For sparse parameters, use :py:meth:`Parameter.list_row_sparse_data`</span> <span class="sd"> instead.</span> @@ -1366,9 +1366,9 @@ <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"Cannot return copies of Parameter '</span><span class="si">%s</span><span class="s2">' on all contexts via "</span> \ <span class="s2">"list_data() because its storage type is </span><span class="si">%s</span><span class="s2">. Please use "</span> \ <span class="s2">"row_sparse_data() instead."</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_stype</span><span class="p">))</span> - <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_check_and_get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">,</span> <span class="nb">list</span><span class="p">)</span> + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_check_and_get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">,</span> <span class="nb">list</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">grad</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> +<div class="viewcode-block" id="Parameter.grad"><a class="viewcode-back" href="../../../api/gluon/parameter.html#mxnet.gluon.Parameter.grad">[docs]</a> <span class="k">def</span> <span class="nf">grad</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> <span class="sd">"""Returns a gradient buffer for this parameter on one context.</span> <span class="sd"> Parameters</span> @@ -1380,34 +1380,34 @@ <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span> <span class="s2">"Cannot get gradient array for Parameter '</span><span class="si">%s</span><span class="s2">' "</span> \ <span class="s2">"because grad_req='null'"</span><span class="o">%</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> - <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_check_and_get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_grad</span><span class="p">,</span> <span class="n">ctx</span><span class="p">)</span> + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_check_and_get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_grad</span><span class="p">,</span> <span class="n">ctx</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">list_grad</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +<div class="viewcode-block" id="Parameter.list_grad"><a class="viewcode-back" href="../../../api/gluon/parameter.html#mxnet.gluon.Parameter.list_grad">[docs]</a> <span class="k">def</span> <span class="nf">list_grad</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""Returns gradient buffers on all contexts, in the same order</span> <span class="sd"> as :py:meth:`values`."""</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_grad</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span> <span class="s2">"Cannot get gradient array for Parameter '</span><span class="si">%s</span><span class="s2">' "</span> \ <span class="s2">"because grad_req='null'"</span><span class="o">%</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">))</span> - <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_check_and_get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_grad</span><span class="p">,</span> <span class="nb">list</span><span class="p">)</span> + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_check_and_get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_grad</span><span class="p">,</span> <span class="nb">list</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">list_ctx</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +<div class="viewcode-block" id="Parameter.list_ctx"><a class="viewcode-back" href="../../../api/gluon/parameter.html#mxnet.gluon.Parameter.list_ctx">[docs]</a> <span class="k">def</span> <span class="nf">list_ctx</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""Returns a list of contexts this parameter is initialized on."""</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_deferred_init</span><span class="p">:</span> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_deferred_init</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">"Parameter '</span><span class="si">%s</span><span class="s2">' has not been initialized"</span><span class="o">%</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> - <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ctx_list</span> + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ctx_list</span></div> - <span class="k">def</span> <span class="nf">zero_grad</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +<div class="viewcode-block" id="Parameter.zero_grad"><a class="viewcode-back" href="../../../api/gluon/parameter.html#mxnet.gluon.Parameter.zero_grad">[docs]</a> <span class="k">def</span> <span class="nf">zero_grad</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""Sets gradient buffer on all contexts to 0. No action is taken if</span> <span class="sd"> parameter is uninitialized or doesn't require gradient."""</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_grad</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> <span class="k">return</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_grad</span><span class="p">:</span> - <span class="n">ndarray</span><span class="o">.</span><span class="n">zeros_like</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">out</span><span class="o">=</span><span class="n">i</span><span class="p">)</span> + <span class="n">ndarray</span><span class="o">.</span><span class="n">zeros_like</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">out</span><span class="o">=</span><span class="n">i</span><span class="p">)</span></div> - <span class="k">def</span> <span class="nf">var</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +<div class="viewcode-block" id="Parameter.var"><a class="viewcode-back" href="../../../api/gluon/parameter.html#mxnet.gluon.Parameter.var">[docs]</a> <span class="k">def</span> <span class="nf">var</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="sd">"""Returns a symbol representing this parameter."""</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_var</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_var_name</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> <span class="c1"># _var_name is set manually in SymbolBlock.import</span> @@ -1418,9 +1418,9 @@ <span class="n">init</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">init</span><span class="p">,</span> <span class="n">stype</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_stype</span><span class="p">)</span> <span class="k">if</span> <span class="n">is_np_array</span><span class="p">():</span> <span class="bp">self</span><span class="o">.</span><span class="n">_var</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_var</span><span class="o">.</span><span class="n">as_np_ndarray</span><span class="p">()</span> - <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_var</span> + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_var</span></div> - <span class="k">def</span> <span class="nf">cast</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dtype</span><span class="p">):</span> +<div class="viewcode-block" id="Parameter.cast"><a class="viewcode-back" href="../../../api/gluon/parameter.html#mxnet.gluon.Parameter.cast">[docs]</a> <span class="k">def</span> <span class="nf">cast</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dtype</span><span class="p">):</span> <span class="sd">"""Cast data and gradient of this Parameter to a new data type.</span> <span class="sd"> Parameters</span> @@ -1436,7 +1436,7 @@ <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_grad</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_grad</span> <span class="o">=</span> <span class="p">[</span><span class="n">i</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_grad</span><span class="p">]</span> - <span class="n">autograd</span><span class="o">.</span><span class="n">mark_variables</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_grad</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grad_req</span><span class="p">)</span> + <span class="n">autograd</span><span class="o">.</span><span class="n">mark_variables</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_grad</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">grad_req</span><span class="p">)</span></div> <span class="k">def</span> <span class="nf">_check_and_setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span> <span class="sd">"""check and set attributes for parameter"""</span> @@ -1469,9 +1469,9 @@ <span class="s2">"desired '</span><span class="si">%s</span><span class="s2">' vs stored '</span><span class="si">%s</span><span class="s2">'."</span><span class="o">%</span><span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">v</span><span class="p">),</span> <span class="nb">str</span><span class="p">(</span><span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">k</span><span class="p">)))</span> <span class="k">else</span><span class="p">:</span> - <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> + <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span></div> -<div class="viewcode-block" id="Constant"><a class="viewcode-back" href="../../../api/gluon/constant.html#mxnet.gluon.Constant">[docs]</a><span class="k">class</span> <span class="nc">Constant</span><span class="p">(</span><span class="n">Parameter</span><span class="p">):</span> +<span class="k">class</span> <span class="nc">Constant</span><span class="p">(</span><span class="n">Parameter</span><span class="p">):</span> <span class="sd">"""A constant parameter for holding immutable tensors.</span> <span class="sd"> `Constant`s are ignored by `autograd` and `Trainer`, thus their values</span> <span class="sd"> will not change during training. But you can still update their values</span> @@ -1522,7 +1522,7 @@ <span class="k">if</span> <span class="n">req</span> <span class="o">!=</span> <span class="s1">'null'</span><span class="p">:</span> <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s1">'Constant parameter "</span><span class="si">{}</span><span class="s1">" does not support '</span> <span class="s1">'grad_req other than "null", and new value "</span><span class="si">{}</span><span class="s1">" '</span> - <span class="s1">'is ignored.'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">req</span><span class="p">))</span></div> + <span class="s1">'is ignored.'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">req</span><span class="p">))</span> </pre></div> <hr class="feedback-hr-top" /> diff --git a/api/python/docs/_modules/mxnet/util.html b/api/python/docs/_modules/mxnet/util.html index 1786db1..8a2b142 100644 --- a/api/python/docs/_modules/mxnet/util.html +++ b/api/python/docs/_modules/mxnet/util.html @@ -817,7 +817,7 @@ <span class="k">return</span> <span class="n">free_mem</span><span class="o">.</span><span class="n">value</span><span class="p">,</span> <span class="n">total_mem</span><span class="o">.</span><span class="n">value</span> -<div class="viewcode-block" id="set_np_shape"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.set_np_shape">[docs]</a><span class="k">def</span> <span class="nf">set_np_shape</span><span class="p">(</span><span class="n">active</span><span class="p">):</span> +<span class="k">def</span> <span class="nf">set_np_shape</span><span class="p">(</span><span class="n">active</span><span class="p">):</span> <span class="sd">"""Turns on/off NumPy shape semantics, in which `()` represents the shape of scalar tensors,</span> <span class="sd"> and tuples with `0` elements, for example, `(0,)`, `(1, 0, 2)`, represent the shapes</span> <span class="sd"> of zero-size tensors. This is turned off by default for keeping backward compatibility.</span> @@ -861,10 +861,10 @@ <span class="s1">' deactivate both of them.'</span><span class="p">)</span> <span class="n">prev</span> <span class="o">=</span> <span class="n">ctypes</span><span class="o">.</span><span class="n">c_int</span><span class="p">()</span> <span class="n">check_call</span><span class="p">(</span><span class="n">_LIB</span><span class="o">.</span><span class="n">MXSetIsNumpyShape</span><span class="p">(</span><span class="n">ctypes</span><span class="o">.</span><span class="n">c_int</span><span class="p">(</span><span class="n">active</span><span class="p">),</span> <span class="n">ctypes</span><span class="o">.</span><span class="n">byref</span><span class="p">(</span><span class="n">prev</span><span class="p">)))</span> - <span class="k">return</span> <span class="nb">bool</span><span class="p">(</span><span class="n">prev</span><span class="o">.</span><span class="n">value</span><span class="p">)</span></div> + <span class="k">return</span> <span class="nb">bool</span><span class="p">(</span><span class="n">prev</span><span class="o">.</span><span class="n">value</span><span class="p">)</span> -<div class="viewcode-block" id="is_np_shape"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.is_np_shape">[docs]</a><span class="k">def</span> <span class="nf">is_np_shape</span><span class="p">():</span> +<span class="k">def</span> <span class="nf">is_np_shape</span><span class="p">():</span> <span class="sd">"""Checks whether the NumPy shape semantics is currently turned on.</span> <span class="sd"> In NumPy shape semantics, `()` represents the shape of scalar tensors,</span> <span class="sd"> and tuples with `0` elements, for example, `(0,)`, `(1, 0, 2)`, represent</span> @@ -895,7 +895,7 @@ <span class="sd"> """</span> <span class="n">curr</span> <span class="o">=</span> <span class="n">ctypes</span><span class="o">.</span><span class="n">c_bool</span><span class="p">()</span> <span class="n">check_call</span><span class="p">(</span><span class="n">_LIB</span><span class="o">.</span><span class="n">MXIsNumpyShape</span><span class="p">(</span><span class="n">ctypes</span><span class="o">.</span><span class="n">byref</span><span class="p">(</span><span class="n">curr</span><span class="p">)))</span> - <span class="k">return</span> <span class="n">curr</span><span class="o">.</span><span class="n">value</span></div> + <span class="k">return</span> <span class="n">curr</span><span class="o">.</span><span class="n">value</span> <span class="k">class</span> <span class="nc">_NumpyShapeScope</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> @@ -926,7 +926,7 @@ <span class="n">set_np_shape</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev_is_np_shape</span><span class="p">)</span> -<div class="viewcode-block" id="np_shape"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.np_shape">[docs]</a><span class="k">def</span> <span class="nf">np_shape</span><span class="p">(</span><span class="n">active</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> +<span class="k">def</span> <span class="nf">np_shape</span><span class="p">(</span><span class="n">active</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> <span class="sd">"""Returns an activated/deactivated NumPy shape scope to be used in 'with' statement</span> <span class="sd"> and captures code that needs the NumPy shape semantics, i.e. support of scalar and</span> <span class="sd"> zero-size tensors.</span> @@ -992,10 +992,10 @@ <span class="sd"> assert arg_shapes[0] == ()</span> <span class="sd"> assert out_shapes[0] == ()</span> <span class="sd"> """</span> - <span class="k">return</span> <span class="n">_NumpyShapeScope</span><span class="p">(</span><span class="n">active</span><span class="p">)</span></div> + <span class="k">return</span> <span class="n">_NumpyShapeScope</span><span class="p">(</span><span class="n">active</span><span class="p">)</span> -<div class="viewcode-block" id="use_np_shape"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.use_np_shape">[docs]</a><span class="k">def</span> <span class="nf">use_np_shape</span><span class="p">(</span><span class="n">func</span><span class="p">):</span> +<span class="k">def</span> <span class="nf">use_np_shape</span><span class="p">(</span><span class="n">func</span><span class="p">):</span> <span class="sd">"""A decorator wrapping a function or class with activated NumPy-shape semantics.</span> <span class="sd"> When `func` is a function, this ensures that the execution of the function is scoped with NumPy</span> <span class="sd"> shape semantics, such as the support for zero-dim and zero size tensors. When</span> @@ -1066,7 +1066,7 @@ <span class="k">return</span> <span class="n">_with_np_shape</span> <span class="k">else</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s1">'use_np_shape can only decorate classes and callable objects, '</span> - <span class="s1">'while received a </span><span class="si">{}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">func</span><span class="p">))))</span></div> + <span class="s1">'while received a </span><span class="si">{}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">func</span><span class="p">))))</span> <span class="k">def</span> <span class="nf">_sanity_check_params</span><span class="p">(</span><span class="n">func_name</span><span class="p">,</span> <span class="n">unsupported_params</span><span class="p">,</span> <span class="n">param_dict</span><span class="p">):</span> @@ -1076,7 +1076,7 @@ <span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">func_name</span><span class="p">,</span> <span class="n">param_name</span><span class="p">))</span> -<div class="viewcode-block" id="set_module"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.set_module">[docs]</a><span class="k">def</span> <span class="nf">set_module</span><span class="p">(</span><span class="n">module</span><span class="p">):</span> +<span class="k">def</span> <span class="nf">set_module</span><span class="p">(</span><span class="n">module</span><span class="p">):</span> <span class="sd">"""Decorator for overriding __module__ on a function or class.</span> <span class="sd"> Example usage::</span> @@ -1091,7 +1091,7 @@ <span class="k">if</span> <span class="n">module</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> <span class="n">func</span><span class="o">.</span><span class="vm">__module__</span> <span class="o">=</span> <span class="n">module</span> <span class="k">return</span> <span class="n">func</span> - <span class="k">return</span> <span class="n">decorator</span></div> + <span class="k">return</span> <span class="n">decorator</span> <span class="k">class</span> <span class="nc">_NumpyArrayScope</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> @@ -1119,7 +1119,7 @@ <span class="n">_NumpyArrayScope</span><span class="o">.</span><span class="n">_current</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_old_scope</span> -<div class="viewcode-block" id="np_array"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.np_array">[docs]</a><span class="k">def</span> <span class="nf">np_array</span><span class="p">(</span><span class="n">active</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> +<span class="k">def</span> <span class="nf">np_array</span><span class="p">(</span><span class="n">active</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> <span class="sd">"""Returns an activated/deactivated NumPy-array scope to be used in 'with' statement</span> <span class="sd"> and captures code that needs the NumPy-array semantics.</span> @@ -1145,10 +1145,10 @@ <span class="sd"> _NumpyShapeScope</span> <span class="sd"> A scope object for wrapping the code w/ or w/o NumPy-shape semantics.</span> <span class="sd"> """</span> - <span class="k">return</span> <span class="n">_NumpyArrayScope</span><span class="p">(</span><span class="n">active</span><span class="p">)</span></div> + <span class="k">return</span> <span class="n">_NumpyArrayScope</span><span class="p">(</span><span class="n">active</span><span class="p">)</span> -<div class="viewcode-block" id="is_np_array"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.is_np_array">[docs]</a><span class="k">def</span> <span class="nf">is_np_array</span><span class="p">():</span> +<div class="viewcode-block" id="is_np_array"><a class="viewcode-back" href="../../api/mxnet/image/index.html#mxnet.image.is_np_array">[docs]</a><span class="k">def</span> <span class="nf">is_np_array</span><span class="p">():</span> <span class="sd">"""Checks whether the NumPy-array semantics is currently turned on.</span> <span class="sd"> This is currently used in Gluon for checking whether an array of type `mxnet.numpy.ndarray`</span> <span class="sd"> or `mx.nd.NDArray` should be created. For example, at the time when a parameter</span> @@ -1171,7 +1171,7 @@ <span class="n">_NumpyArrayScope</span><span class="o">.</span><span class="n">_current</span><span class="p">,</span> <span class="s2">"value"</span><span class="p">)</span> <span class="k">else</span> <span class="kc">False</span></div> -<div class="viewcode-block" id="use_np_array"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.use_np_array">[docs]</a><span class="k">def</span> <span class="nf">use_np_array</span><span class="p">(</span><span class="n">func</span><span class="p">):</span> +<span class="k">def</span> <span class="nf">use_np_array</span><span class="p">(</span><span class="n">func</span><span class="p">):</span> <span class="sd">"""A decorator wrapping Gluon `Block`s and all its methods, properties, and static functions</span> <span class="sd"> with the semantics of NumPy-array, which means that where ndarrays are created,</span> <span class="sd"> `mxnet.numpy.ndarray`s should be created, instead of legacy ndarrays of type `mx.nd.NDArray`.</span> @@ -1250,10 +1250,10 @@ <span class="k">return</span> <span class="n">_with_np_array</span> <span class="k">else</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s1">'use_np_array can only decorate classes and callable objects, '</span> - <span class="s1">'while received a </span><span class="si">{}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">func</span><span class="p">))))</span></div> + <span class="s1">'while received a </span><span class="si">{}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">func</span><span class="p">))))</span> -<div class="viewcode-block" id="use_np"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.use_np">[docs]</a><span class="k">def</span> <span class="nf">use_np</span><span class="p">(</span><span class="n">func</span><span class="p">):</span> +<span class="k">def</span> <span class="nf">use_np</span><span class="p">(</span><span class="n">func</span><span class="p">):</span> <span class="sd">"""A convenience decorator for wrapping user provided functions and classes in the scope of</span> <span class="sd"> both NumPy-shape and NumPy-array semantics, which means that (1) empty tuples `()` and tuples</span> <span class="sd"> with zeros, such as `(0, 1)`, `(1, 0, 2)`, will be treated as scalar tensors' shapes and</span> @@ -1313,10 +1313,10 @@ <span class="sd"> Function or class</span> <span class="sd"> A function or class wrapped in the Numpy-shape and NumPy-array scope.</span> <span class="sd"> """</span> - <span class="k">return</span> <span class="n">use_np_shape</span><span class="p">(</span><span class="n">use_np_array</span><span class="p">(</span><span class="n">func</span><span class="p">))</span></div> + <span class="k">return</span> <span class="n">use_np_shape</span><span class="p">(</span><span class="n">use_np_array</span><span class="p">(</span><span class="n">func</span><span class="p">))</span> -<div class="viewcode-block" id="np_ufunc_legal_option"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.np_ufunc_legal_option">[docs]</a><span class="k">def</span> <span class="nf">np_ufunc_legal_option</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span> +<span class="k">def</span> <span class="nf">np_ufunc_legal_option</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span> <span class="sd">"""Checking if ufunc arguments are legal inputs</span> <span class="sd"> Parameters</span> @@ -1348,10 +1348,10 @@ <span class="s1">'float16'</span><span class="p">,</span> <span class="s1">'float32'</span><span class="p">,</span> <span class="s1">'float64'</span><span class="p">]))</span> <span class="k">elif</span> <span class="n">key</span> <span class="o">==</span> <span class="s1">'subok'</span><span class="p">:</span> <span class="k">return</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">bool</span><span class="p">)</span> - <span class="k">return</span> <span class="kc">False</span></div> + <span class="k">return</span> <span class="kc">False</span> -<div class="viewcode-block" id="wrap_np_unary_func"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.wrap_np_unary_func">[docs]</a><span class="k">def</span> <span class="nf">wrap_np_unary_func</span><span class="p">(</span><span class="n">func</span><span class="p">):</span> +<span class="k">def</span> <span class="nf">wrap_np_unary_func</span><span class="p">(</span><span class="n">func</span><span class="p">):</span> <span class="sd">"""A convenience decorator for wrapping numpy-compatible unary ufuncs to provide uniform</span> <span class="sd"> error handling.</span> @@ -1381,10 +1381,10 @@ <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s2">"</span><span class="si">{}</span><span class="s2">=</span><span class="si">{}</span><span class="s2"> not understood for operator </span><span class="si">{}</span><span class="s2">"</span> <span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">func</span><span class="o">.</span><span class="vm">__name__</span><span class="p">))</span> <span class="k">return</span> <span class="n">func</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">out</span><span class="o">=</span><span class="n">out</span><span class="p">)</span> - <span class="k">return</span> <span class="n">_wrap_np_unary_func</span></div> + <span class="k">return</span> <span class="n">_wrap_np_unary_func</span> -<div class="viewcode-block" id="wrap_np_binary_func"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.wrap_np_binary_func">[docs]</a><span class="k">def</span> <span class="nf">wrap_np_binary_func</span><span class="p">(</span><span class="n">func</span><span class="p">):</span> +<span class="k">def</span> <span class="nf">wrap_np_binary_func</span><span class="p">(</span><span class="n">func</span><span class="p">):</span> <span class="sd">"""A convenience decorator for wrapping numpy-compatible binary ufuncs to provide uniform</span> <span class="sd"> error handling.</span> @@ -1412,11 +1412,11 @@ <span class="c1"># otherwise raise TypeError with not understood error message</span> <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s2">"</span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2"> not understood"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">))</span> <span class="k">return</span> <span class="n">func</span><span class="p">(</span><span class="n">x1</span><span class="p">,</span> <span class="n">x2</span><span class="p">,</span> <span class="n">out</span><span class="o">=</span><span class="n">out</span><span class="p">)</span> - <span class="k">return</span> <span class="n">_wrap_np_binary_func</span></div> + <span class="k">return</span> <span class="n">_wrap_np_binary_func</span> <span class="c1"># pylint: disable=exec-used</span> -<div class="viewcode-block" id="numpy_fallback"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.numpy_fallback">[docs]</a><span class="k">def</span> <span class="nf">numpy_fallback</span><span class="p">(</span><span class="n">func</span><span class="p">):</span> +<span class="k">def</span> <span class="nf">numpy_fallback</span><span class="p">(</span><span class="n">func</span><span class="p">):</span> <span class="sd">"""decorator for falling back to offical numpy for a specific function"""</span> <span class="k">def</span> <span class="nf">get_ctx</span><span class="p">(</span><span class="n">ctx</span><span class="p">,</span> <span class="n">new_ctx</span><span class="p">):</span> <span class="k">if</span> <span class="n">ctx</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> @@ -1498,7 +1498,7 @@ <span class="n">ret</span> <span class="o">=</span> <span class="n">_as_mx_np_array</span><span class="p">(</span><span class="n">ret</span><span class="p">,</span> <span class="n">ctx</span><span class="o">=</span><span class="n">ctx</span><span class="p">)</span> <span class="k">return</span> <span class="n">ret</span> - <span class="k">return</span> <span class="n">_fallback_to_official_np</span></div> + <span class="k">return</span> <span class="n">_fallback_to_official_np</span> <span class="c1"># pylint: enable=exec-used</span> @@ -1528,7 +1528,7 @@ <span class="k">return</span> <span class="n">cur_state</span> -<div class="viewcode-block" id="set_np"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.set_np">[docs]</a><span class="k">def</span> <span class="nf">set_np</span><span class="p">(</span><span class="n">shape</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">array</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="kc"> [...] +<span class="k">def</span> <span class="nf">set_np</span><span class="p">(</span><span class="n">shape</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">array</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span> <span class="sd">"""Setting NumPy shape and array semantics at the same time.</span> <span class="sd"> It is required to keep NumPy shape semantics active while activating NumPy array semantics.</span> <span class="sd"> Deactivating NumPy shape semantics while NumPy array semantics is still active is not allowed.</span> @@ -1612,18 +1612,18 @@ <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'NumPy Shape semantics is required in using NumPy array semantics.'</span><span class="p">)</span> <span class="n">_set_np_array</span><span class="p">(</span><span class="n">array</span><span class="p">)</span> <span class="n">set_np_shape</span><span class="p">(</span><span class="n">shape</span><span class="p">)</span> - <span class="n">set_np_default_dtype</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span></div> + <span class="n">set_np_default_dtype</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span> -<div class="viewcode-block" id="reset_np"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.reset_np">[docs]</a><span class="k">def</span> <span class="nf">reset_np</span><span class="p">():</span> +<span class="k">def</span> <span class="nf">reset_np</span><span class="p">():</span> <span class="sd">"""Deactivate NumPy shape and array and deafult dtype semantics at the same time."""</span> - <span class="n">set_np</span><span class="p">(</span><span class="n">shape</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">array</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span></div> + <span class="n">set_np</span><span class="p">(</span><span class="n">shape</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">array</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> <span class="n">_CUDA_SUCCESS</span> <span class="o">=</span> <span class="mi">0</span> -<div class="viewcode-block" id="get_cuda_compute_capability"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.get_cuda_compute_capability">[docs]</a><span class="k">def</span> <span class="nf">get_cuda_compute_capability</span><span class="p">(</span><span class="n">ctx</span><span class="p">):</span> +<span class="k">def</span> <span class="nf">get_cuda_compute_capability</span><span class="p">(</span><span class="n">ctx</span><span class="p">):</span> <span class="sd">"""Returns the cuda compute capability of the input `ctx`.</span> <span class="sd"> Parameters</span> @@ -1678,9 +1678,9 @@ <span class="n">cuda</span><span class="o">.</span><span class="n">cuGetErrorString</span><span class="p">(</span><span class="n">ret</span><span class="p">,</span> <span class="n">ctypes</span><span class="o">.</span><span class="n">byref</span><span class="p">(</span><span class="n">error_str</span><span class="p">))</span> <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s1">'cuDeviceComputeCapability failed with error code </span><span class="si">{}</span><span class="s1">: </span><span class="si">{}</span><span class="s1">'</span> <span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">ret</span><span class="p">,</span> <span class="n">error_str</span><span class="o">.</span><span class="n">value</span><span class="o">.</span><span class="n">decode</span><span class="p">()))</span> - <span class="k">return</span> <span class="n">cc_major</span><span class="o">.</span><span class="n">value</span> <span class="o">*</span> <span class="mi">10</span> <span class="o">+</span> <span class="n">cc_minor</span><span class="o">.</span><span class="n">value</span></div> + <span class="k">return</span> <span class="n">cc_major</span><span class="o">.</span><span class="n">value</span> <span class="o">*</span> <span class="mi">10</span> <span class="o">+</span> <span class="n">cc_minor</span><span class="o">.</span><span class="n">value</span> -<div class="viewcode-block" id="default_array"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.default_array">[docs]</a><span class="k">def</span> <span class="nf">default_array</span><span class="p">(</span><span class="n">source_array</span><span class="p">,</span> <span class="n">ctx</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="kc">None</span><span class="p" [...] +<span class="k">def</span> <span class="nf">default_array</span><span class="p">(</span><span class="n">source_array</span><span class="p">,</span> <span class="n">ctx</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span> <span class="sd">"""Creates an array from any object exposing the default(nd or np) array interface.</span> <span class="sd"> Parameters</span> @@ -1704,7 +1704,7 @@ <span class="k">if</span> <span class="n">is_np_array</span><span class="p">():</span> <span class="k">return</span> <span class="n">_mx_np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">source_array</span><span class="p">,</span> <span class="n">ctx</span><span class="o">=</span><span class="n">ctx</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">dtype</span><span class="p">)</span> <span class="k">else</span><span class="p">:</span> - <span class="k">return</span> <span class="n">_mx_nd</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">source_array</span><span class="p">,</span> <span class="n">ctx</span><span class="o">=</span><span class="n">ctx</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">dtype</span><span class="p">)</span></div> + <span class="k">return</span> <span class="n">_mx_nd</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">source_array</span><span class="p">,</span> <span class="n">ctx</span><span class="o">=</span><span class="n">ctx</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="n">dtype</span><span class="p">)</span> <span class="k">class</span> <span class="nc">_NumpyDefaultDtypeScope</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> <span class="sd">"""Scope for managing NumPy default dtype semantics.</span> @@ -1734,7 +1734,7 @@ <span class="bp">self</span><span class="o">.</span><span class="n">_prev_is_np_default_dtype</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_enter_is_np_default_dtype</span><span class="p">:</span> <span class="n">set_np_default_dtype</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_prev_is_np_default_dtype</span><span class="p">)</span> -<div class="viewcode-block" id="np_default_dtype"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.np_default_dtype">[docs]</a><span class="k">def</span> <span class="nf">np_default_dtype</span><span class="p">(</span><span class="n">active</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> +<span class="k">def</span> <span class="nf">np_default_dtype</span><span class="p">(</span><span class="n">active</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> <span class="sd">"""Returns an activated/deactivated NumPy-default_dtype scope to be used in 'with' statement</span> <span class="sd"> and captures code that needs the NumPy default dtype semantics. i.e. default dtype is float64.</span> @@ -1766,9 +1766,9 @@ <span class="sd"> assert arr.dtype == 'float32'</span> <span class="sd"> """</span> - <span class="k">return</span> <span class="n">_NumpyDefaultDtypeScope</span><span class="p">(</span><span class="n">active</span><span class="p">)</span></div> + <span class="k">return</span> <span class="n">_NumpyDefaultDtypeScope</span><span class="p">(</span><span class="n">active</span><span class="p">)</span> -<div class="viewcode-block" id="use_np_default_dtype"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.use_np_default_dtype">[docs]</a><span class="k">def</span> <span class="nf">use_np_default_dtype</span><span class="p">(</span><span class="n">func</span><span class="p">):</span> +<span class="k">def</span> <span class="nf">use_np_default_dtype</span><span class="p">(</span><span class="n">func</span><span class="p">):</span> <span class="sd">"""A decorator wrapping a function or class with activated NumPy-default_dtype semantics.</span> <span class="sd"> When `func` is a function, this ensures that the execution of the function is scoped with NumPy</span> <span class="sd"> default dtype semantics, with the support for float64 as default dtype.</span> @@ -1838,9 +1838,9 @@ <span class="k">return</span> <span class="n">_with_np_default_dtype</span> <span class="k">else</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s1">'use_np_default_dtype can only decorate classes and callable objects, '</span> - <span class="s1">'while received a </span><span class="si">{}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">func</span><span class="p">))))</span></div> + <span class="s1">'while received a </span><span class="si">{}</span><span class="s1">'</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">func</span><span class="p">))))</span> -<div class="viewcode-block" id="is_np_default_dtype"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.is_np_default_dtype">[docs]</a><span class="k">def</span> <span class="nf">is_np_default_dtype</span><span class="p">():</span> +<span class="k">def</span> <span class="nf">is_np_default_dtype</span><span class="p">():</span> <span class="sd">"""Checks whether the NumPy default dtype semantics is currently turned on.</span> <span class="sd"> In NumPy default dtype semantics, default dtype is float64.</span> @@ -1870,9 +1870,9 @@ <span class="sd"> """</span> <span class="n">curr</span> <span class="o">=</span> <span class="n">ctypes</span><span class="o">.</span><span class="n">c_bool</span><span class="p">()</span> <span class="n">check_call</span><span class="p">(</span><span class="n">_LIB</span><span class="o">.</span><span class="n">MXIsNumpyDefaultDtype</span><span class="p">(</span><span class="n">ctypes</span><span class="o">.</span><span class="n">byref</span><span class="p">(</span><span class="n">curr</span><span class="p">)))</span> - <span class="k">return</span> <span class="n">curr</span><span class="o">.</span><span class="n">value</span></div> + <span class="k">return</span> <span class="n">curr</span><span class="o">.</span><span class="n">value</span> -<div class="viewcode-block" id="set_np_default_dtype"><a class="viewcode-back" href="../../api/mxnet/util/index.html#mxnet.util.set_np_default_dtype">[docs]</a><span class="k">def</span> <span class="nf">set_np_default_dtype</span><span class="p">(</span><span class="n">is_np_default_dtype</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> <span class="c1"># pylint: disable=redefined-outer-name</span> +<span class="k">def</span> <span class="nf">set_np_default_dtype</span><span class="p">(</span><span class="n">is_np_default_dtype</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span> <span class="c1"># pylint: disable=redefined-outer-name</span> <span class="sd">"""Turns on/off NumPy default dtype semantics, because mxnet.numpy.ndarray use</span> <span class="sd"> 32 bit data storage as default (e.g. float32 and int 32) while offical NumPy use</span> <span class="sd"> 64 bit data storage as default (e.g. float64 and int64).</span> @@ -1910,7 +1910,7 @@ <span class="n">_set_np_default_dtype_logged</span> <span class="o">=</span> <span class="kc">True</span> <span class="n">prev</span> <span class="o">=</span> <span class="n">ctypes</span><span class="o">.</span><span class="n">c_bool</span><span class="p">()</span> <span class="n">check_call</span><span class="p">(</span><span class="n">_LIB</span><span class="o">.</span><span class="n">MXSetIsNumpyDefaultDtype</span><span class="p">(</span><span class="n">ctypes</span><span class="o">.</span><span class="n">c_bool</span><span class="p">(</span><span class="n">is_np_default_dtype</span><span class="p">),</span> <span class="n">ctypes</span><span class="o">.</span><span class="n">byref</span><span class="p">(</span><span class="n">prev</span><sp [...] - <span class="k">return</span> <span class="n">prev</span><span class="o">.</span><span class="n">value</span></div> + <span class="k">return</span> <span class="n">prev</span><span class="o">.</span><span class="n">value</span> </pre></div> <hr class="feedback-hr-top" /> diff --git a/date.txt b/date.txt deleted file mode 100644 index a1bf3b8..0000000 --- a/date.txt +++ /dev/null @@ -1 +0,0 @@ -Fri Jul 17 06:43:35 UTC 2020 diff --git a/feed.xml b/feed.xml index f270c48..075512e 100644 --- a/feed.xml +++ b/feed.xml @@ -1 +1 @@ -<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.0.0">Jekyll</generator><link href="https://mxnet.apache.org/feed.xml" rel="self" type="application/atom+xml" /><link href="https://mxnet.apache.org/" rel="alternate" type="text/html" /><updated>2020-07-17T06:30:36+00:00</updated><id>https://mxnet.apache.org/feed.xml</id><title type="html">Apache MXNet</title><subtitle>A flexible and efficient library for deep [...] \ No newline at end of file +<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.0.0">Jekyll</generator><link href="https://mxnet.apache.org/feed.xml" rel="self" type="application/atom+xml" /><link href="https://mxnet.apache.org/" rel="alternate" type="text/html" /><updated>2020-07-17T12:29:52+00:00</updated><id>https://mxnet.apache.org/feed.xml</id><title type="html">Apache MXNet</title><subtitle>A flexible and efficient library for deep [...] \ No newline at end of file