| <!DOCTYPE html> |
| <html lang=" en"><head> |
| <meta charset="utf-8"> |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| <meta name="viewport" content="width=device-width, initial-scale=1"> |
| <link href="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/mxnet-icon.png" rel="icon" type="image/png"><!-- Begin Jekyll SEO tag v2.6.1 --> |
| <title>Examine forward results with hooks | Apache MXNet</title> |
| <meta name="generator" content="Jekyll v4.0.0" /> |
| <meta property="og:title" content="Examine forward results with hooks" /> |
| <meta property="og:locale" content="en_US" /> |
| <meta name="description" content="A flexible and efficient library for deep learning." /> |
| <meta property="og:description" content="A flexible and efficient library for deep learning." /> |
| <link rel="canonical" href="https://mxnet.apache.org/api/dev-guide/examine_forward_results_with_hooks" /> |
| <meta property="og:url" content="https://mxnet.apache.org/api/dev-guide/examine_forward_results_with_hooks" /> |
| <meta property="og:site_name" content="Apache MXNet" /> |
| <script type="application/ld+json"> |
| {"url":"https://mxnet.apache.org/api/dev-guide/examine_forward_results_with_hooks","headline":"Examine forward results with hooks","description":"A flexible and efficient library for deep learning.","@type":"WebPage","@context":"https://schema.org"}</script> |
| <!-- End Jekyll SEO tag --> |
| <script src="https://medium-widget.pixelpoint.io/widget.js"></script> |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" /> |
| <link rel="stylesheet" href="/assets/main.css"><link type="application/atom+xml" rel="alternate" href="https://mxnet.apache.org/feed.xml" title="Apache MXNet" /><script> |
| if(!(window.doNotTrack === "1" || navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1")) { |
| (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
| (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
| m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
| })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); |
| |
| ga('create', 'UA-96378503-1', 'auto'); |
| ga('send', 'pageview'); |
| } |
| </script> |
| |
| <script src="/assets/js/jquery-3.3.1.min.js"></script><script src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js" defer></script> |
| <script src="/assets/js/globalSearch.js" defer></script> |
| <script src="/assets/js/clipboard.js" defer></script> |
| <script src="/assets/js/copycode.js" defer></script></head> |
| <body><header class="site-header" role="banner"> |
| |
| <script> |
| $(document).ready(function () { |
| |
| // HEADER OPACITY LOGIC |
| |
| function opacity_header() { |
| var value = "rgba(4,140,204," + ($(window).scrollTop() / 300 + 0.4) + ")" |
| $('.site-header').css("background-color", value) |
| } |
| |
| $(window).scroll(function () { |
| opacity_header() |
| }) |
| opacity_header(); |
| |
| // MENU SELECTOR LOGIC |
| $('.page-link').each( function () { |
| if (window.location.href.includes(this.href)) { |
| $(this).addClass("page-current"); |
| } |
| }); |
| }) |
| </script> |
| <div class="wrapper"> |
| <a class="site-title" rel="author" href="/"><img |
| src="/assets/img/mxnet_logo.png" class="site-header-logo"></a> |
| <nav class="site-nav"> |
| <input type="checkbox" id="nav-trigger" class="nav-trigger"/> |
| <label for="nav-trigger"> |
| <span class="menu-icon"> |
| <svg viewBox="0 0 18 15" width="18px" height="15px"> |
| <path d="M18,1.484c0,0.82-0.665,1.484-1.484,1.484H1.484C0.665,2.969,0,2.304,0,1.484l0,0C0,0.665,0.665,0,1.484,0 h15.032C17.335,0,18,0.665,18,1.484L18,1.484z M18,7.516C18,8.335,17.335,9,16.516,9H1.484C0.665,9,0,8.335,0,7.516l0,0 c0-0.82,0.665-1.484,1.484-1.484h15.032C17.335,6.031,18,6.696,18,7.516L18,7.516z M18,13.516C18,14.335,17.335,15,16.516,15H1.484 C0.665,15,0,14.335,0,13.516l0,0c0-0.82,0.665-1.483,1.484-1.483h15.032C17.335,12.031,18,12.695,18,13.516L18,13.516z"/> |
| </svg> |
| </span> |
| </label> |
| <div class="gs-search-border"> |
| <div id="gs-search-icon"></div> |
| <form id="global-search-form"> |
| <input id="global-search" type="text" title="Search" placeholder="Search" /> |
| <div id="global-search-dropdown-container"> |
| <button class="gs-current-version btn" type="button" data-toggle="dropdown"> |
| <span id="gs-current-version-label">master</span> |
| <svg class="gs-dropdown-caret" viewBox="0 0 32 32" class="icon icon-caret-bottom" aria-hidden="true"> |
| <path class="dropdown-caret-path" d="M24 11.305l-7.997 11.39L8 11.305z"></path> |
| </svg> |
| </button> |
| <ul class="gs-opt-group gs-version-dropdown"> |
| |
| |
| <li class="gs-opt gs-versions active">master</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">1.7</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">1.6</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">1.5.0</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">1.4.1</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">1.3.1</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">1.2.1</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">1.1.0</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">1.0.0</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">0.12.1</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">0.11.0</li> |
| |
| |
| </ul> |
| </div> |
| <span id="global-search-close">x</span> |
| </form> |
| </div> |
| <div class="trigger"> |
| <div id="global-search-mobile-border"> |
| <div id="gs-search-icon-mobile"></div> |
| <input id="global-search-mobile" placeholder="Search..." type="text"/> |
| <div id="global-search-dropdown-container-mobile"> |
| <button class="gs-current-version-mobile btn" type="button" data-toggle="dropdown"> |
| <svg class="gs-dropdown-caret" viewBox="0 0 32 32" class="icon icon-caret-bottom" aria-hidden="true"> |
| <path class="dropdown-caret-path" d="M24 11.305l-7.997 11.39L8 11.305z"></path> |
| </svg> |
| </button> |
| <ul class="gs-opt-group gs-version-dropdown-mobile"> |
| |
| |
| <li class="gs-opt gs-versions active">master</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">1.7</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">1.6</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">1.5.0</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">1.4.1</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">1.3.1</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">1.2.1</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">1.1.0</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">1.0.0</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">0.12.1</li> |
| |
| |
| |
| <li class="gs-opt gs-versions">0.11.0</li> |
| |
| |
| </ul> |
| </div> |
| </div> |
| <a class="page-link" href="/get_started">Get Started</a> |
| <a class="page-link" href="/blog">Blog</a> |
| <a class="page-link" href="/features">Features</a> |
| <a class="page-link" href="/ecosystem">Ecosystem</a> |
| <a class="page-link" href="/api">Docs & Tutorials</a> |
| <a class="page-link" href="https://github.com/apache/incubator-mxnet">GitHub</a> |
| <div class="dropdown"> |
| <span class="dropdown-header">master |
| <svg class="dropdown-caret" viewBox="0 0 32 32" class="icon icon-caret-bottom" aria-hidden="true"><path class="dropdown-caret-path" d="M24 11.305l-7.997 11.39L8 11.305z"></path></svg> |
| </span> |
| <div class="dropdown-content"> |
| |
| |
| <a class="dropdown-option-active" href="/">master</a> |
| |
| |
| |
| <a href="/versions/1.7/">1.7</a> |
| |
| |
| |
| <a href="/versions/1.6/">1.6</a> |
| |
| |
| |
| <a href="/versions/1.5.0/">1.5.0</a> |
| |
| |
| |
| <a href="/versions/1.4.1/">1.4.1</a> |
| |
| |
| |
| <a href="/versions/1.3.1/">1.3.1</a> |
| |
| |
| |
| <a href="/versions/1.2.1/">1.2.1</a> |
| |
| |
| |
| <a href="/versions/1.1.0/">1.1.0</a> |
| |
| |
| |
| <a href="/versions/1.0.0/">1.0.0</a> |
| |
| |
| |
| <a href="/versions/0.12.1/">0.12.1</a> |
| |
| |
| |
| <a href="/versions/0.11.0/">0.11.0</a> |
| |
| |
| </div> |
| </div> |
| </div> |
| </nav> |
| </div> |
| </header> |
| <main class="page-content" aria-label="Content"> |
| <script> |
| |
| </script> |
| <article class="post"> |
| |
| <header class="post-header wrapper"> |
| <h1 class="post-title">Examine forward results with hooks</h1> |
| <h3></h3></header> |
| |
| <div class="post-content"> |
| <div class="wrapper"> |
| <div class="row"> |
| <div class="col-3 docs-side-bar"> |
| <h3 style="text-transform: capitalize; padding-left:10px">Developer Guide</h3> |
| <ul> |
| |
| |
| <li><a href="/api/dev-guide/github_contribution_and_PR_verification_tips">GitHub contribution and PR verification tips</a></li> |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| |
| <li><a href="/api/dev-guide/debugging_and_performance_optimization_tips">Debugging and performance optimization tips</a></li> |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| |
| <li><a href="/api/dev-guide/examine_forward_results_with_hooks">Examine forward results with hooks</a></li> |
| <!-- page-category --> |
| |
| |
| <li><a href="/api/dev-guide/exception_handing_and_custom_error_types">Exception handing and custom error types</a></li> |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| |
| <li><a href="/api/dev-guide/profiling">Profiling</a></li> |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| |
| <!-- page-category --> |
| <!-- resource-p --> |
| </ul> |
| </div> |
| <div class="col-9"> |
| <!--- Licensed to the Apache Software Foundation (ASF) under one --> |
| <!--- or more contributor license agreements. See the NOTICE file --> |
| <!--- distributed with this work for additional information --> |
| <!--- regarding copyright ownership. The ASF licenses this file --> |
| <!--- to you under the Apache License, Version 2.0 (the --> |
| <!--- "License"); you may not use this file except in compliance --> |
| <!--- with the License. You may obtain a copy of the License at --> |
| |
| <!--- http://www.apache.org/licenses/LICENSE-2.0 --> |
| |
| <!--- Unless required by applicable law or agreed to in writing, --> |
| <!--- software distributed under the License is distributed on an --> |
| <!--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --> |
| <!--- KIND, either express or implied. See the License for the --> |
| <!--- specific language governing permissions and limitations --> |
| <!--- under the License. --> |
| |
| <h1 id="examine-forward-results-with-hooks">Examine forward results with hooks</h1> |
| |
| <p>There are currently three ways to register a function in an MXNet Gluon Block for execution:</p> |
| |
| <ul> |
| <li>before <code class="highlighter-rouge">forward</code> via <a href="/api/python/docs/api/gluon/block.html#mxnet.gluon.Block.register_forward_pre_hook">register_forward_pre_hook</a></li> |
| <li>after <code class="highlighter-rouge">forward</code> via <a href="/api/python/docs/api/gluon/block.html#mxnet.gluon.Block.register_forward_hook">register_forward_hook</a></li> |
| <li>as a callback via <a href="/api/python/docs/api/gluon/block.html#mxnet.gluon.Block.register_op_hook">register_op_hook</a></li> |
| </ul> |
| |
| <h2 id="pre-forward-hook">Pre-forward hook</h2> |
| |
| <p>To register a hook prior to forward execution, the requirement is that the registered operation <strong>should not modify the input or output</strong>. For example: <code class="highlighter-rouge">hook(block, input) -> None</code>. This is useful to get a summary before execution.</p> |
| |
| <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>import mxnet as mx |
| from mxnet.gluon import nn |
| |
| block = nn.Dense(10) |
| block.initialize() |
| print("{}".format(block)) |
| # Dense(None -> 10, linear) |
| |
| def pre_hook(block, input) -> None: # notice it has two arguments, one block and one input |
| print("{}".format(block)) |
| return |
| |
| # register |
| pre_handle = block.register_forward_pre_hook(pre_hook) |
| input = mx.nd.ones((3, 5)) |
| print(block(input)) |
| |
| # Dense(None -> 10, linear) |
| # [[ 0.11254273 0.11162187 0.02200389 -0.04842059 0.09531345 0.00880495 |
| # -0.07610667 0.1562067 0.14192852 0.04463106] |
| # [ 0.11254273 0.11162187 0.02200389 -0.04842059 0.09531345 0.00880495 |
| # -0.07610667 0.1562067 0.14192852 0.04463106] |
| # [ 0.11254273 0.11162187 0.02200389 -0.04842059 0.09531345 0.00880495 |
| # -0.07610667 0.1562067 0.14192852 0.04463106]] |
| # <NDArray 3x10 @cpu(0)> |
| </code></pre></div></div> |
| |
| <p>We can <code class="highlighter-rouge">detach</code> a hook from a block:</p> |
| |
| <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>pre_handle.detach() |
| print(block(input)) |
| |
| # [[ 0.11254273 0.11162187 0.02200389 -0.04842059 0.09531345 0.00880495 |
| # -0.07610667 0.1562067 0.14192852 0.04463106] |
| # [ 0.11254273 0.11162187 0.02200389 -0.04842059 0.09531345 0.00880495 |
| # -0.07610667 0.1562067 0.14192852 0.04463106] |
| # [ 0.11254273 0.11162187 0.02200389 -0.04842059 0.09531345 0.00880495 |
| # -0.07610667 0.1562067 0.14192852 0.04463106]] |
| # <NDArray 3x10 @cpu(0)> |
| </code></pre></div></div> |
| |
| <p>Notice <code class="highlighter-rouge">Dense(None -> 10, linear)</code> is not displayed anymore.</p> |
| |
| <h2 id="post-forward-hook">Post-forward hook</h2> |
| |
| <p>Registering a hook after forward execution is very similar to pre-forward hook (as explained above) with the difference that the hook signature should be <code class="highlighter-rouge">hook(block, input, output) -> None</code> where <strong>hook should not modify the input and output.</strong> Continuing from the above example:</p> |
| |
| <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>def post_hook(block, intput, output) -> None: |
| print("{}".format(block)) |
| return |
| |
| post_handle = block.register_forward_hook(post_hook) |
| print(block(input)) |
| |
| # Dense(5 -> 10, linear) |
| # [[ 0.11254273 0.11162187 0.02200389 -0.04842059 0.09531345 0.00880495 |
| # -0.07610667 0.1562067 0.14192852 0.04463106] |
| # [ 0.11254273 0.11162187 0.02200389 -0.04842059 0.09531345 0.00880495 |
| # -0.07610667 0.1562067 0.14192852 0.04463106] |
| # [ 0.11254273 0.11162187 0.02200389 -0.04842059 0.09531345 0.00880495 |
| # -0.07610667 0.1562067 0.14192852 0.04463106]] |
| # <NDArray 3x10 @cpu(0)> |
| </code></pre></div></div> |
| |
| <p>Notice the difference between <code class="highlighter-rouge">pre_hook</code> and <code class="highlighter-rouge">post_hook</code> results due to shape inference after <code class="highlighter-rouge">forward</code> is done executing.</p> |
| |
| <h2 id="callback-hook">Callback hook</h2> |
| |
| <p>We can register a callback monitor to monitor all operators that are called by the <code class="highlighter-rouge">HybridBlock</code> <strong>after hybridization</strong> with <code class="highlighter-rouge">register_op_hook(callback, monitor_all=False) </code> where the callback signature should be:</p> |
| |
| <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>callback(node_name: str, opr_name: str, arr: NDArray) -> None |
| </code></pre></div></div> |
| |
| <p>where <code class="highlighter-rouge">node_name</code> is the name of the tensor being inspected (str), <code class="highlighter-rouge">opr_name</code> is the name of the operator producing or consuming that tensor (str) and <code class="highlighter-rouge">arr</code> the tensor being inspected (NDArray).</p> |
| |
| <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">import</span> <span class="n">mxnet</span> <span class="k">as</span> <span class="n">mx</span> |
| <span class="k">from</span> <span class="n">mxnet</span><span class="p">.</span><span class="n">gluon</span> <span class="n">import</span> <span class="n">nn</span> |
| |
| <span class="n">def</span> <span class="n">mon_callback</span><span class="p">(</span><span class="n">node_name</span><span class="p">,</span> <span class="n">opr_name</span><span class="p">,</span> <span class="n">arr</span><span class="p">):</span> |
| <span class="n">print</span><span class="p">(</span><span class="s2">"{}"</span><span class="p">.</span><span class="n">format</span><span class="p">(</span><span class="n">node_name</span><span class="p">))</span> |
| <span class="n">print</span><span class="p">(</span><span class="s2">"{}"</span><span class="p">.</span><span class="n">format</span><span class="p">(</span><span class="n">opr_name</span><span class="p">))</span> |
| <span class="n">return</span> |
| |
| <span class="k">model</span> <span class="p">=</span> <span class="n">nn</span><span class="p">.</span><span class="n">HybridSequential</span><span class="p">(</span><span class="n">prefix</span><span class="p">=</span><span class="s2">"dense_"</span><span class="p">)</span> |
| <span class="k">with</span> <span class="k">model</span><span class="p">.</span><span class="n">name_scope</span><span class="p">():</span> |
| <span class="k">model</span><span class="p">.</span><span class="n">add</span><span class="p">(</span><span class="n">mx</span><span class="p">.</span><span class="n">gluon</span><span class="p">.</span><span class="n">nn</span><span class="p">.</span><span class="n">Dense</span><span class="p">(</span><span class="m">2</span><span class="p">))</span> |
| |
| <span class="k">model</span><span class="p">.</span><span class="n">initialize</span><span class="p">()</span> |
| <span class="k">model</span><span class="p">.</span><span class="n">hybridize</span><span class="p">()</span> |
| <span class="k">model</span><span class="p">.</span><span class="n">register_op_hook</span><span class="p">(</span><span class="n">mon_callback</span><span class="p">,</span> <span class="n">monitor_all</span><span class="p">=</span><span class="nb">True</span><span class="p">)</span> |
| <span class="n">print</span><span class="p">(</span><span class="k">model</span><span class="p">(</span><span class="n">mx</span><span class="p">.</span><span class="n">nd</span><span class="p">.</span><span class="n">ones</span><span class="p">((</span><span class="m">2</span><span class="p">,</span> <span class="m">3</span><span class="p">,</span> <span class="m">4</span><span class="p">))))</span> |
| |
| <span class="p">#</span> <span class="n">b</span><span class="s1">'dense_dense0_fwd_data'</span> |
| <span class="p">#</span> <span class="n">b</span><span class="s1">'FullyConnected'</span> |
| <span class="p">#</span> <span class="n">b</span><span class="s1">'dense_dense0_fwd_weight'</span> |
| <span class="p">#</span> <span class="n">b</span><span class="s1">'FullyConnected'</span> |
| <span class="p">#</span> <span class="n">b</span><span class="s1">'dense_dense0_fwd_bias'</span> |
| <span class="p">#</span> <span class="n">b</span><span class="s1">'FullyConnected'</span> |
| <span class="p">#</span> <span class="n">b</span><span class="s1">'dense_dense0_fwd_output'</span> |
| <span class="p">#</span> <span class="n">b</span><span class="s1">'FullyConnected'</span> |
| <span class="p">#</span> <span class="p">[[-</span><span class="m">0.05979988</span> <span class="p">-</span><span class="m">0.16349721</span><span class="p">]</span> |
| <span class="p">#</span> <span class="p">[-</span><span class="m">0.05979988</span> <span class="p">-</span><span class="m">0.16349721</span><span class="p">]]</span> |
| <span class="p">#</span> <span class="p"><</span><span class="n">NDArray</span> <span class="m">2</span><span class="n">x2</span> <span class="p">@</span><span class="n">cpu</span><span class="p">(</span><span class="m">0</span><span class="p">)></span> |
| </code></pre></div></div> |
| |
| <p>Setting <code class="highlighter-rouge">monitor_all=False</code> will print only the output:</p> |
| |
| <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>`# b'dense_dense0_fwd_output'` |
| `# b'FullyConnected'`` |
| # [[-0.05979988 -0.16349721] |
| # [-0.05979988 -0.16349721]] |
| # <NDArray 2x2 @cpu(0)` |
| </code></pre></div></div> |
| |
| <p>Note that to get the internal operator node names, one can use <code class="highlighter-rouge">model.collect_params().items()</code>.</p> |
| |
| </div> |
| </div> |
| |
| </div> |
| </div> |
| |
| </article> |
| |
| </main><footer class="site-footer h-card"> |
| <div class="wrapper"> |
| <div class="row"> |
| <div class="col-4"> |
| <h4 class="footer-category-title">Resources</h4> |
| <ul class="contact-list"> |
| <li><a href="/community#stay-connected">Mailing lists</a></li> |
| <li><a href="https://discuss.mxnet.io">MXNet Discuss forum</a></li> |
| <li><a href="/community#github-issues">Github Issues</a></li> |
| <li><a href="https://github.com/apache/incubator-mxnet/projects">Projects</a></li> |
| <li><a href="https://cwiki.apache.org/confluence/display/MXNET/Apache+MXNet+Home">Developer Wiki</a></li> |
| <li><a href="/community">Contribute To MXNet</a></li> |
| |
| </ul> |
| </div> |
| |
| <div class="col-4"><ul class="social-media-list"><li><a href="https://github.com/apache/incubator-mxnet"><svg class="svg-icon"><use xlink:href="/assets/minima-social-icons.svg#github"></use></svg> <span class="username">apache/incubator-mxnet</span></a></li><li><a href="https://www.twitter.com/apachemxnet"><svg class="svg-icon"><use xlink:href="/assets/minima-social-icons.svg#twitter"></use></svg> <span class="username">apachemxnet</span></a></li><li><a href="https://youtube.com/apachemxnet"><svg class="svg-icon"><use xlink:href="/assets/minima-social-icons.svg#youtube"></use></svg> <span class="username">apachemxnet</span></a></li></ul> |
| </div> |
| |
| <div class="col-4 footer-text"> |
| <p>A flexible and efficient library for deep learning.</p> |
| </div> |
| </div> |
| </div> |
| </footer> |
| <footer class="site-footer2"> |
| <div class="wrapper"> |
| <div class="row"> |
| <div class="col-3"> |
| <img src="/assets/img/apache_incubator_logo.png" class="footer-logo col-2"> |
| </div> |
| <div class="footer-bottom-warning col-9"> |
| <p>Apache MXNet is an effort undergoing incubation at The Apache Software Foundation (ASF), <span |
| style="font-weight:bold">sponsored by the <i>Apache Incubator</i></span>. Incubation is required |
| of all newly accepted projects until a further review indicates that the infrastructure, |
| communications, and decision making process have stabilized in a manner consistent with other |
| successful ASF projects. While incubation status is not necessarily a reflection of the completeness |
| or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF. |
| </p><p>"Copyright © 2017-2018, The Apache Software Foundation Apache MXNet, MXNet, Apache, the Apache |
| feather, and the Apache MXNet project logo are either registered trademarks or trademarks of the |
| Apache Software Foundation."</p> |
| </div> |
| </div> |
| </div> |
| </footer> |
| |
| |
| |
| |
| </body> |
| |
| </html> |