| <!DOCTYPE html> |
| |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <meta charset="utf-8" /> |
| <meta charset="utf-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
| <meta http-equiv="x-ua-compatible" content="ie=edge"> |
| <style> |
| .dropdown { |
| position: relative; |
| display: inline-block; |
| } |
| |
| .dropdown-content { |
| display: none; |
| position: absolute; |
| background-color: #f9f9f9; |
| min-width: 160px; |
| box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); |
| padding: 12px 16px; |
| z-index: 1; |
| text-align: left; |
| } |
| |
| .dropdown:hover .dropdown-content { |
| display: block; |
| } |
| |
| .dropdown-option:hover { |
| color: #FF4500; |
| } |
| |
| .dropdown-option-active { |
| color: #FF4500; |
| font-weight: lighter; |
| } |
| |
| .dropdown-option { |
| color: #000000; |
| font-weight: lighter; |
| } |
| |
| .dropdown-header { |
| color: #FFFFFF; |
| display: inline-flex; |
| } |
| |
| .dropdown-caret { |
| width: 18px; |
| } |
| |
| .dropdown-caret-path { |
| fill: #FFFFFF; |
| } |
| </style> |
| |
| <title>mxnet.module — Apache MXNet documentation</title> |
| |
| <link rel="stylesheet" href="../../_static/basic.css" type="text/css" /> |
| <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> |
| <link rel="stylesheet" type="text/css" href="../../_static/mxnet.css" /> |
| <link rel="stylesheet" href="../../_static/material-design-lite-1.3.0/material.blue-deep_orange.min.css" type="text/css" /> |
| <link rel="stylesheet" href="../../_static/sphinx_materialdesign_theme.css" type="text/css" /> |
| <link rel="stylesheet" href="../../_static/fontawesome/all.css" type="text/css" /> |
| <link rel="stylesheet" href="../../_static/fonts.css" type="text/css" /> |
| <link rel="stylesheet" href="../../_static/feedback.css" type="text/css" /> |
| <script id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script> |
| <script src="../../_static/jquery.js"></script> |
| <script src="../../_static/underscore.js"></script> |
| <script src="../../_static/doctools.js"></script> |
| <script src="../../_static/language_data.js"></script> |
| <script src="../../_static/google_analytics.js"></script> |
| <script src="../../_static/autodoc.js"></script> |
| <script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script> |
| <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script> |
| <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true, "ignoreClass": "document", "processClass": "math|output_area"}})</script> |
| <link rel="shortcut icon" href="../../_static/mxnet-icon.png"/> |
| <link rel="index" title="Index" href="../../genindex.html" /> |
| <link rel="search" title="Search" href="../../search.html" /> |
| <link rel="next" title="mxnet.contrib" href="../contrib/index.html" /> |
| <link rel="prev" title="symbol.sparse" href="../symbol/sparse/index.html" /> |
| </head> |
| <body><header class="site-header" role="banner"> |
| <div class="wrapper"> |
| <a class="site-title" rel="author" href="/versions/1.8.0/"><img |
| src="../../_static/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="trigger"> |
| <a class="page-link" href="/versions/1.8.0/get_started">Get Started</a> |
| <a class="page-link" href="/versions/1.8.0/blog">Blog</a> |
| <a class="page-link" href="/versions/1.8.0/features">Features</a> |
| <a class="page-link" href="/versions/1.8.0/ecosystem">Ecosystem</a> |
| <a class="page-link page-current" href="/versions/1.8.0/api">Docs & Tutorials</a> |
| <a class="page-link" href="https://github.com/apache/incubator-mxnet">GitHub</a> |
| <div class="dropdown"> |
| <span class="dropdown-header">1.8.0 |
| <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" href="/">master</a><br> |
| <a class="dropdown-option-active" href="/versions/1.8.0/">1.8.0</a><br> |
| <a class="dropdown-option" href="/versions/1.7.0/">1.7.0</a><br> |
| <a class="dropdown-option" href="/versions/1.6.0/">1.6.0</a><br> |
| <a class="dropdown-option" href="/versions/1.5.0/">1.5.0</a><br> |
| <a class="dropdown-option" href="/versions/1.4.1/">1.4.1</a><br> |
| <a class="dropdown-option" href="/versions/1.3.1/">1.3.1</a><br> |
| <a class="dropdown-option" href="/versions/1.2.1/">1.2.1</a><br> |
| <a class="dropdown-option" href="/versions/1.1.0/">1.1.0</a><br> |
| <a class="dropdown-option" href="/versions/1.0.0/">1.0.0</a><br> |
| <a class="dropdown-option" href="/versions/0.12.1/">0.12.1</a><br> |
| <a class="dropdown-option" href="/versions/0.11.0/">0.11.0</a> |
| </div> |
| </div> |
| </div> |
| </nav> |
| </div> |
| </header> |
| <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer"><header class="mdl-layout__header mdl-layout__header--waterfall "> |
| <div class="mdl-layout__header-row"> |
| |
| <nav class="mdl-navigation breadcrumb"> |
| <a class="mdl-navigation__link" href="../index.html">Python API</a><i class="material-icons">navigate_next</i> |
| <a class="mdl-navigation__link is-active">mxnet.module</a> |
| </nav> |
| <div class="mdl-layout-spacer"></div> |
| <nav class="mdl-navigation"> |
| |
| <form class="form-inline pull-sm-right" action="../../search.html" method="get"> |
| <div class="mdl-textfield mdl-js-textfield mdl-textfield--expandable mdl-textfield--floating-label mdl-textfield--align-right"> |
| <label id="quick-search-icon" class="mdl-button mdl-js-button mdl-button--icon" for="waterfall-exp"> |
| <i class="material-icons">search</i> |
| </label> |
| <div class="mdl-textfield__expandable-holder"> |
| <input class="mdl-textfield__input" type="text" name="q" id="waterfall-exp" placeholder="Search" /> |
| <input type="hidden" name="check_keywords" value="yes" /> |
| <input type="hidden" name="area" value="default" /> |
| </div> |
| </div> |
| <div class="mdl-tooltip" data-mdl-for="quick-search-icon"> |
| Quick search |
| </div> |
| </form> |
| |
| <a id="button-show-source" |
| class="mdl-button mdl-js-button mdl-button--icon" |
| href="../../_sources/api/module/index.rst" rel="nofollow"> |
| <i class="material-icons">code</i> |
| </a> |
| <div class="mdl-tooltip" data-mdl-for="button-show-source"> |
| Show Source |
| </div> |
| </nav> |
| </div> |
| <div class="mdl-layout__header-row header-links"> |
| <div class="mdl-layout-spacer"></div> |
| <nav class="mdl-navigation"> |
| </nav> |
| </div> |
| </header><header class="mdl-layout__drawer"> |
| |
| <div class="globaltoc"> |
| <span class="mdl-layout-title toc">Table Of Contents</span> |
| |
| |
| |
| <nav class="mdl-navigation"> |
| <ul class="current"> |
| <li class="toctree-l1"><a class="reference internal" href="../../tutorials/index.html">Python Tutorials</a><ul> |
| <li class="toctree-l2"><a class="reference internal" href="../../tutorials/getting-started/index.html">Getting Started</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/getting-started/crash-course/index.html">Crash Course</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/getting-started/crash-course/1-ndarray.html">Manipulate data with <code class="docutils literal notranslate"><span class="pre">ndarray</span></code></a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/getting-started/crash-course/2-nn.html">Create a neural network</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/getting-started/crash-course/3-autograd.html">Automatic differentiation with <code class="docutils literal notranslate"><span class="pre">autograd</span></code></a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/getting-started/crash-course/4-train.html">Train the neural network</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/getting-started/crash-course/5-predict.html">Predict with a pre-trained model</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/getting-started/crash-course/6-use_gpus.html">Use GPUs</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/getting-started/to-mxnet/index.html">Moving to MXNet from Other Frameworks</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/getting-started/to-mxnet/pytorch.html">PyTorch vs Apache MXNet</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/getting-started/gluon_from_experiment_to_deployment.html">Gluon: from experiment to deployment</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/getting-started/logistic_regression_explained.html">Logistic regression explained</a></li> |
| <li class="toctree-l3"><a class="reference external" href="https://mxnet.apache.org/api/python/docs/tutorials/packages/gluon/image/mnist.html">MNIST</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="../../tutorials/packages/index.html">Packages</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/packages/autograd/index.html">Automatic Differentiation</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/packages/gluon/index.html">Gluon</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/index.html">Blocks</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/custom-layer.html">Custom Layers</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/custom_layer_beginners.html">Customer Layers (Beginners)</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/hybridize.html">Hybridize</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/init.html">Initialization</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/naming.html">Parameter and Block Naming</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/nn.html">Layers and Blocks</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/parameters.html">Parameter Management</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/save_load_params.html">Saving and Loading Gluon Models</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/activations/activations.html">Activation Blocks</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/gluon/data/index.html">Data Tutorials</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/data/data_augmentation.html">Image Augmentation</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/data/data_augmentation.html#Spatial-Augmentation">Spatial Augmentation</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/data/data_augmentation.html#Color-Augmentation">Color Augmentation</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/data/data_augmentation.html#Composed-Augmentations">Composed Augmentations</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/data/datasets.html">Gluon <code class="docutils literal notranslate"><span class="pre">Dataset</span></code>s and <code class="docutils literal notranslate"><span class="pre">DataLoader</span></code></a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/data/datasets.html#Using-own-data-with-included-Datasets">Using own data with included <code class="docutils literal notranslate"><span class="pre">Dataset</span></code>s</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/data/datasets.html#Using-own-data-with-custom-Datasets">Using own data with custom <code class="docutils literal notranslate"><span class="pre">Dataset</span></code>s</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/data/datasets.html#Appendix:-Upgrading-from-Module-DataIter-to-Gluon-DataLoader">Appendix: Upgrading from Module <code class="docutils literal notranslate"><span class="pre">DataIter</span></code> to Gluon <code class="docutils literal notranslate"><span class="pre">DataLoader</span></code></a></li> |
| </ul> |
| </li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/gluon/image/index.html">Image Tutorials</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/image/image-augmentation.html">Image Augmentation</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/image/info_gan.html">Image similarity search with InfoGAN</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/image/mnist.html">Handwritten Digit Recognition</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/image/pretrained_models.html">Using pre-trained models in MXNet</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/gluon/loss/index.html">Losses</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/loss/custom-loss.html">Custom Loss Blocks</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/loss/kl_divergence.html">Kullback-Leibler (KL) Divergence</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/loss/loss.html">Loss functions</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/gluon/text/index.html">Text Tutorials</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/text/gnmt.html">Google Neural Machine Translation</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/text/transformer.html">Machine Translation with Transformer</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/gluon/training/index.html">Training</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/training/fit_api_tutorial.html">MXNet Gluon Fit API</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/training/trainer.html">Trainer</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/training/learning_rates/index.html">Learning Rates</a><ul> |
| <li class="toctree-l6"><a class="reference internal" href="../../tutorials/packages/gluon/training/learning_rates/learning_rate_finder.html">Learning Rate Finder</a></li> |
| <li class="toctree-l6"><a class="reference internal" href="../../tutorials/packages/gluon/training/learning_rates/learning_rate_schedules.html">Learning Rate Schedules</a></li> |
| <li class="toctree-l6"><a class="reference internal" href="../../tutorials/packages/gluon/training/learning_rates/learning_rate_schedules_advanced.html">Advanced Learning Rate Schedules</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/training/normalization/index.html">Normalization Blocks</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/packages/kvstore/index.html">KVStore</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/kvstore/kvstore.html">Distributed Key-Value Store</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/packages/ndarray/index.html">NDArray</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/ndarray/01-ndarray-intro.html">An Intro: Manipulate Data the MXNet Way with NDArray</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/ndarray/02-ndarray-operations.html">NDArray Operations</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/ndarray/03-ndarray-contexts.html">NDArray Contexts</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/ndarray/gotchas_numpy_in_mxnet.html">Gotchas using NumPy in Apache MXNet</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/ndarray/sparse/index.html">Tutorials</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/ndarray/sparse/csr.html">CSRNDArray - NDArray in Compressed Sparse Row Storage Format</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/ndarray/sparse/row_sparse.html">RowSparseNDArray - NDArray for Sparse Gradient Updates</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/ndarray/sparse/train.html">Train a Linear Regression Model with Sparse Symbols</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/ndarray/sparse/train_gluon.html">Sparse NDArrays with Gluon</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/packages/onnx/index.html">ONNX</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/onnx/fine_tuning_gluon.html">Fine-tuning an ONNX model</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/onnx/inference_on_onnx_model.html">Running inference on MXNet/Gluon from an ONNX model</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/onnx/super_resolution.html">Importing an ONNX model into MXNet</a></li> |
| <li class="toctree-l4"><a class="reference external" href="https://mxnet.apache.org/api/python/docs/tutorials/deploy/export/onnx.html">Export ONNX Models</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/packages/optimizer/index.html">Optimizers</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/packages/viz/index.html">Visualization</a><ul> |
| <li class="toctree-l4"><a class="reference external" href="https://mxnet.apache.org/api/faq/visualize_graph">Visualize networks</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="../../tutorials/performance/index.html">Performance</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/performance/compression/index.html">Compression</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/performance/compression/int8.html">Deploy with int-8</a></li> |
| <li class="toctree-l4"><a class="reference external" href="https://mxnet.apache.org/api/faq/float16">Float16</a></li> |
| <li class="toctree-l4"><a class="reference external" href="https://mxnet.apache.org/api/faq/gradient_compression">Gradient Compression</a></li> |
| <li class="toctree-l4"><a class="reference external" href="https://gluon-cv.mxnet.io/build/examples_deployment/int8_inference.html">GluonCV with Quantized Models</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/performance/backend/index.html">Accelerated Backend Tools</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/performance/backend/mkldnn/index.html">Intel MKL-DNN</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/performance/backend/mkldnn/mkldnn_quantization.html">Quantize with MKL-DNN backend</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/performance/backend/mkldnn/mkldnn_readme.html">Install MXNet with MKL-DNN</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/performance/backend/tensorrt/index.html">TensorRT</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/performance/backend/tensorrt/tensorrt.html">Optimizing Deep Learning Computation Graphs with TensorRT</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/performance/backend/tvm.html">Use TVM</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/performance/backend/profiler.html">Profiling MXNet Models</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/performance/backend/amp.html">Using AMP: Automatic Mixed Precision</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="../../tutorials/deploy/index.html">Deployment</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/deploy/export/index.html">Export</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/deploy/export/onnx.html">Exporting to ONNX format</a></li> |
| <li class="toctree-l4"><a class="reference external" href="https://gluon-cv.mxnet.io/build/examples_deployment/export_network.html">Export Gluon CV Models</a></li> |
| <li class="toctree-l4"><a class="reference external" href="https://mxnet.apache.org/api/python/docs/tutorials/packages/gluon/blocks/save_load_params.html">Save / Load Parameters</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/deploy/inference/index.html">Inference</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/deploy/inference/cpp.html">Deploy into C++</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/deploy/inference/image_classification_jetson.html">Image Classication using pretrained ResNet-50 model on Jetson module</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/deploy/inference/scala.html">Deploy into a Java or Scala Environment</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/deploy/inference/wine_detector.html">Real-time Object Detection with MXNet On The Raspberry Pi</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/deploy/run-on-aws/index.html">Run on AWS</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/deploy/run-on-aws/use_ec2.html">Run on an EC2 Instance</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/deploy/run-on-aws/use_sagemaker.html">Run on Amazon SageMaker</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/deploy/run-on-aws/cloud.html">MXNet on the Cloud</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="../../tutorials/extend/index.html">Extend</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/extend/custom_layer.html">Custom Layers</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/extend/customop.html">Custom Numpy Operators</a></li> |
| <li class="toctree-l3"><a class="reference external" href="https://mxnet.apache.org/api/faq/new_op">New Operator Creation</a></li> |
| <li class="toctree-l3"><a class="reference external" href="https://mxnet.apache.org/api/faq/add_op_in_backend">New Operator in MXNet Backend</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l1 current"><a class="reference internal" href="../index.html">Python API</a><ul class="current"> |
| <li class="toctree-l2"><a class="reference internal" href="../ndarray/index.html">mxnet.ndarray</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../ndarray/ndarray.html">ndarray</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ndarray/contrib/index.html">ndarray.contrib</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ndarray/image/index.html">ndarray.image</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ndarray/linalg/index.html">ndarray.linalg</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ndarray/op/index.html">ndarray.op</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ndarray/random/index.html">ndarray.random</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ndarray/register/index.html">ndarray.register</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ndarray/sparse/index.html">ndarray.sparse</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ndarray/utils/index.html">ndarray.utils</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="../gluon/index.html">mxnet.gluon</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/block.html">gluon.Block</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/hybrid_block.html">gluon.HybridBlock</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/symbol_block.html">gluon.SymbolBlock</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/constant.html">gluon.Constant</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/parameter.html">gluon.Parameter</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/parameter_dict.html">gluon.ParameterDict</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/trainer.html">gluon.Trainer</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/contrib/index.html">gluon.contrib</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/data/index.html">gluon.data</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../gluon/data/vision/index.html">data.vision</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../gluon/data/vision/datasets/index.html">vision.datasets</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../gluon/data/vision/transforms/index.html">vision.transforms</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/loss/index.html">gluon.loss</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/model_zoo/index.html">gluon.model_zoo.vision</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/nn/index.html">gluon.nn</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/rnn/index.html">gluon.rnn</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/utils/index.html">gluon.utils</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="../autograd/index.html">mxnet.autograd</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../initializer/index.html">mxnet.initializer</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../optimizer/index.html">mxnet.optimizer</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../lr_scheduler/index.html">mxnet.lr_scheduler</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../metric/index.html">mxnet.metric</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../kvstore/index.html">mxnet.kvstore</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../symbol/index.html">mxnet.symbol</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../symbol/symbol.html">symbol</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../symbol/contrib/index.html">symbol.contrib</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../symbol/image/index.html">symbol.image</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../symbol/linalg/index.html">symbol.linalg</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../symbol/op/index.html">symbol.op</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../symbol/random/index.html">symbol.random</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../symbol/register/index.html">symbol.register</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../symbol/sparse/index.html">symbol.sparse</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2 current"><a class="current reference internal" href="#">mxnet.module</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../contrib/index.html">mxnet.contrib</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../contrib/autograd/index.html">contrib.autograd</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../contrib/io/index.html">contrib.io</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../contrib/ndarray/index.html">contrib.ndarray</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../contrib/onnx/index.html">contrib.onnx</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../contrib/quantization/index.html">contrib.quantization</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../contrib/symbol/index.html">contrib.symbol</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../contrib/tensorboard/index.html">contrib.tensorboard</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../contrib/tensorrt/index.html">contrib.tensorrt</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../contrib/text/index.html">contrib.text</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="../mxnet/index.html">mxnet</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/attribute/index.html">mxnet.attribute</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/base/index.html">mxnet.base</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/callback/index.html">mxnet.callback</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/context/index.html">mxnet.context</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/engine/index.html">mxnet.engine</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/executor/index.html">mxnet.executor</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/executor_manager/index.html">mxnet.executor_manager</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/image/index.html">mxnet.image</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/io/index.html">mxnet.io</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/kvstore_server/index.html">mxnet.kvstore_server</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/libinfo/index.html">mxnet.libinfo</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/log/index.html">mxnet.log</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/model/index.html">mxnet.model</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/monitor/index.html">mxnet.monitor</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/name/index.html">mxnet.name</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/notebook/index.html">mxnet.notebook</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/operator/index.html">mxnet.operator</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/profiler/index.html">mxnet.profiler</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/random/index.html">mxnet.random</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/recordio/index.html">mxnet.recordio</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/registry/index.html">mxnet.registry</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/rtc/index.html">mxnet.rtc</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/runtime/index.html">mxnet.runtime</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/test_utils/index.html">mxnet.test_utils</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/torch/index.html">mxnet.torch</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/util/index.html">mxnet.util</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/visualization/index.html">mxnet.visualization</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| |
| </nav> |
| |
| </div> |
| |
| </header> |
| <main class="mdl-layout__content" tabIndex="0"> |
| |
| <script type="text/javascript" src="../../_static/sphinx_materialdesign_theme.js "></script> |
| <script type="text/javascript" src="../../_static/feedback.js"></script> |
| <header class="mdl-layout__drawer"> |
| |
| <div class="globaltoc"> |
| <span class="mdl-layout-title toc">Table Of Contents</span> |
| |
| |
| |
| <nav class="mdl-navigation"> |
| <ul class="current"> |
| <li class="toctree-l1"><a class="reference internal" href="../../tutorials/index.html">Python Tutorials</a><ul> |
| <li class="toctree-l2"><a class="reference internal" href="../../tutorials/getting-started/index.html">Getting Started</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/getting-started/crash-course/index.html">Crash Course</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/getting-started/crash-course/1-ndarray.html">Manipulate data with <code class="docutils literal notranslate"><span class="pre">ndarray</span></code></a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/getting-started/crash-course/2-nn.html">Create a neural network</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/getting-started/crash-course/3-autograd.html">Automatic differentiation with <code class="docutils literal notranslate"><span class="pre">autograd</span></code></a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/getting-started/crash-course/4-train.html">Train the neural network</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/getting-started/crash-course/5-predict.html">Predict with a pre-trained model</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/getting-started/crash-course/6-use_gpus.html">Use GPUs</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/getting-started/to-mxnet/index.html">Moving to MXNet from Other Frameworks</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/getting-started/to-mxnet/pytorch.html">PyTorch vs Apache MXNet</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/getting-started/gluon_from_experiment_to_deployment.html">Gluon: from experiment to deployment</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/getting-started/logistic_regression_explained.html">Logistic regression explained</a></li> |
| <li class="toctree-l3"><a class="reference external" href="https://mxnet.apache.org/api/python/docs/tutorials/packages/gluon/image/mnist.html">MNIST</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="../../tutorials/packages/index.html">Packages</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/packages/autograd/index.html">Automatic Differentiation</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/packages/gluon/index.html">Gluon</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/index.html">Blocks</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/custom-layer.html">Custom Layers</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/custom_layer_beginners.html">Customer Layers (Beginners)</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/hybridize.html">Hybridize</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/init.html">Initialization</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/naming.html">Parameter and Block Naming</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/nn.html">Layers and Blocks</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/parameters.html">Parameter Management</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/save_load_params.html">Saving and Loading Gluon Models</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/blocks/activations/activations.html">Activation Blocks</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/gluon/data/index.html">Data Tutorials</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/data/data_augmentation.html">Image Augmentation</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/data/data_augmentation.html#Spatial-Augmentation">Spatial Augmentation</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/data/data_augmentation.html#Color-Augmentation">Color Augmentation</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/data/data_augmentation.html#Composed-Augmentations">Composed Augmentations</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/data/datasets.html">Gluon <code class="docutils literal notranslate"><span class="pre">Dataset</span></code>s and <code class="docutils literal notranslate"><span class="pre">DataLoader</span></code></a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/data/datasets.html#Using-own-data-with-included-Datasets">Using own data with included <code class="docutils literal notranslate"><span class="pre">Dataset</span></code>s</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/data/datasets.html#Using-own-data-with-custom-Datasets">Using own data with custom <code class="docutils literal notranslate"><span class="pre">Dataset</span></code>s</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/data/datasets.html#Appendix:-Upgrading-from-Module-DataIter-to-Gluon-DataLoader">Appendix: Upgrading from Module <code class="docutils literal notranslate"><span class="pre">DataIter</span></code> to Gluon <code class="docutils literal notranslate"><span class="pre">DataLoader</span></code></a></li> |
| </ul> |
| </li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/gluon/image/index.html">Image Tutorials</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/image/image-augmentation.html">Image Augmentation</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/image/info_gan.html">Image similarity search with InfoGAN</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/image/mnist.html">Handwritten Digit Recognition</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/image/pretrained_models.html">Using pre-trained models in MXNet</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/gluon/loss/index.html">Losses</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/loss/custom-loss.html">Custom Loss Blocks</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/loss/kl_divergence.html">Kullback-Leibler (KL) Divergence</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/loss/loss.html">Loss functions</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/gluon/text/index.html">Text Tutorials</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/text/gnmt.html">Google Neural Machine Translation</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/text/transformer.html">Machine Translation with Transformer</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/gluon/training/index.html">Training</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/training/fit_api_tutorial.html">MXNet Gluon Fit API</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/training/trainer.html">Trainer</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/training/learning_rates/index.html">Learning Rates</a><ul> |
| <li class="toctree-l6"><a class="reference internal" href="../../tutorials/packages/gluon/training/learning_rates/learning_rate_finder.html">Learning Rate Finder</a></li> |
| <li class="toctree-l6"><a class="reference internal" href="../../tutorials/packages/gluon/training/learning_rates/learning_rate_schedules.html">Learning Rate Schedules</a></li> |
| <li class="toctree-l6"><a class="reference internal" href="../../tutorials/packages/gluon/training/learning_rates/learning_rate_schedules_advanced.html">Advanced Learning Rate Schedules</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/gluon/training/normalization/index.html">Normalization Blocks</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/packages/kvstore/index.html">KVStore</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/kvstore/kvstore.html">Distributed Key-Value Store</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/packages/ndarray/index.html">NDArray</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/ndarray/01-ndarray-intro.html">An Intro: Manipulate Data the MXNet Way with NDArray</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/ndarray/02-ndarray-operations.html">NDArray Operations</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/ndarray/03-ndarray-contexts.html">NDArray Contexts</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/ndarray/gotchas_numpy_in_mxnet.html">Gotchas using NumPy in Apache MXNet</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/ndarray/sparse/index.html">Tutorials</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/ndarray/sparse/csr.html">CSRNDArray - NDArray in Compressed Sparse Row Storage Format</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/ndarray/sparse/row_sparse.html">RowSparseNDArray - NDArray for Sparse Gradient Updates</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/ndarray/sparse/train.html">Train a Linear Regression Model with Sparse Symbols</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/packages/ndarray/sparse/train_gluon.html">Sparse NDArrays with Gluon</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/packages/onnx/index.html">ONNX</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/onnx/fine_tuning_gluon.html">Fine-tuning an ONNX model</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/onnx/inference_on_onnx_model.html">Running inference on MXNet/Gluon from an ONNX model</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/packages/onnx/super_resolution.html">Importing an ONNX model into MXNet</a></li> |
| <li class="toctree-l4"><a class="reference external" href="https://mxnet.apache.org/api/python/docs/tutorials/deploy/export/onnx.html">Export ONNX Models</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/packages/optimizer/index.html">Optimizers</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/packages/viz/index.html">Visualization</a><ul> |
| <li class="toctree-l4"><a class="reference external" href="https://mxnet.apache.org/api/faq/visualize_graph">Visualize networks</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="../../tutorials/performance/index.html">Performance</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/performance/compression/index.html">Compression</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/performance/compression/int8.html">Deploy with int-8</a></li> |
| <li class="toctree-l4"><a class="reference external" href="https://mxnet.apache.org/api/faq/float16">Float16</a></li> |
| <li class="toctree-l4"><a class="reference external" href="https://mxnet.apache.org/api/faq/gradient_compression">Gradient Compression</a></li> |
| <li class="toctree-l4"><a class="reference external" href="https://gluon-cv.mxnet.io/build/examples_deployment/int8_inference.html">GluonCV with Quantized Models</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/performance/backend/index.html">Accelerated Backend Tools</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/performance/backend/mkldnn/index.html">Intel MKL-DNN</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/performance/backend/mkldnn/mkldnn_quantization.html">Quantize with MKL-DNN backend</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/performance/backend/mkldnn/mkldnn_readme.html">Install MXNet with MKL-DNN</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/performance/backend/tensorrt/index.html">TensorRT</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../../tutorials/performance/backend/tensorrt/tensorrt.html">Optimizing Deep Learning Computation Graphs with TensorRT</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/performance/backend/tvm.html">Use TVM</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/performance/backend/profiler.html">Profiling MXNet Models</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/performance/backend/amp.html">Using AMP: Automatic Mixed Precision</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="../../tutorials/deploy/index.html">Deployment</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/deploy/export/index.html">Export</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/deploy/export/onnx.html">Exporting to ONNX format</a></li> |
| <li class="toctree-l4"><a class="reference external" href="https://gluon-cv.mxnet.io/build/examples_deployment/export_network.html">Export Gluon CV Models</a></li> |
| <li class="toctree-l4"><a class="reference external" href="https://mxnet.apache.org/api/python/docs/tutorials/packages/gluon/blocks/save_load_params.html">Save / Load Parameters</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/deploy/inference/index.html">Inference</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/deploy/inference/cpp.html">Deploy into C++</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/deploy/inference/image_classification_jetson.html">Image Classication using pretrained ResNet-50 model on Jetson module</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/deploy/inference/scala.html">Deploy into a Java or Scala Environment</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/deploy/inference/wine_detector.html">Real-time Object Detection with MXNet On The Raspberry Pi</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/deploy/run-on-aws/index.html">Run on AWS</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/deploy/run-on-aws/use_ec2.html">Run on an EC2 Instance</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/deploy/run-on-aws/use_sagemaker.html">Run on Amazon SageMaker</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="../../tutorials/deploy/run-on-aws/cloud.html">MXNet on the Cloud</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="../../tutorials/extend/index.html">Extend</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/extend/custom_layer.html">Custom Layers</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../../tutorials/extend/customop.html">Custom Numpy Operators</a></li> |
| <li class="toctree-l3"><a class="reference external" href="https://mxnet.apache.org/api/faq/new_op">New Operator Creation</a></li> |
| <li class="toctree-l3"><a class="reference external" href="https://mxnet.apache.org/api/faq/add_op_in_backend">New Operator in MXNet Backend</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l1 current"><a class="reference internal" href="../index.html">Python API</a><ul class="current"> |
| <li class="toctree-l2"><a class="reference internal" href="../ndarray/index.html">mxnet.ndarray</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../ndarray/ndarray.html">ndarray</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ndarray/contrib/index.html">ndarray.contrib</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ndarray/image/index.html">ndarray.image</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ndarray/linalg/index.html">ndarray.linalg</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ndarray/op/index.html">ndarray.op</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ndarray/random/index.html">ndarray.random</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ndarray/register/index.html">ndarray.register</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ndarray/sparse/index.html">ndarray.sparse</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ndarray/utils/index.html">ndarray.utils</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="../gluon/index.html">mxnet.gluon</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/block.html">gluon.Block</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/hybrid_block.html">gluon.HybridBlock</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/symbol_block.html">gluon.SymbolBlock</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/constant.html">gluon.Constant</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/parameter.html">gluon.Parameter</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/parameter_dict.html">gluon.ParameterDict</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/trainer.html">gluon.Trainer</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/contrib/index.html">gluon.contrib</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/data/index.html">gluon.data</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="../gluon/data/vision/index.html">data.vision</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="../gluon/data/vision/datasets/index.html">vision.datasets</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="../gluon/data/vision/transforms/index.html">vision.transforms</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/loss/index.html">gluon.loss</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/model_zoo/index.html">gluon.model_zoo.vision</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/nn/index.html">gluon.nn</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/rnn/index.html">gluon.rnn</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gluon/utils/index.html">gluon.utils</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="../autograd/index.html">mxnet.autograd</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../initializer/index.html">mxnet.initializer</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../optimizer/index.html">mxnet.optimizer</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../lr_scheduler/index.html">mxnet.lr_scheduler</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../metric/index.html">mxnet.metric</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../kvstore/index.html">mxnet.kvstore</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../symbol/index.html">mxnet.symbol</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../symbol/symbol.html">symbol</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../symbol/contrib/index.html">symbol.contrib</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../symbol/image/index.html">symbol.image</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../symbol/linalg/index.html">symbol.linalg</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../symbol/op/index.html">symbol.op</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../symbol/random/index.html">symbol.random</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../symbol/register/index.html">symbol.register</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../symbol/sparse/index.html">symbol.sparse</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2 current"><a class="current reference internal" href="#">mxnet.module</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../contrib/index.html">mxnet.contrib</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../contrib/autograd/index.html">contrib.autograd</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../contrib/io/index.html">contrib.io</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../contrib/ndarray/index.html">contrib.ndarray</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../contrib/onnx/index.html">contrib.onnx</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../contrib/quantization/index.html">contrib.quantization</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../contrib/symbol/index.html">contrib.symbol</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../contrib/tensorboard/index.html">contrib.tensorboard</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../contrib/tensorrt/index.html">contrib.tensorrt</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../contrib/text/index.html">contrib.text</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="../mxnet/index.html">mxnet</a><ul> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/attribute/index.html">mxnet.attribute</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/base/index.html">mxnet.base</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/callback/index.html">mxnet.callback</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/context/index.html">mxnet.context</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/engine/index.html">mxnet.engine</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/executor/index.html">mxnet.executor</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/executor_manager/index.html">mxnet.executor_manager</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/image/index.html">mxnet.image</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/io/index.html">mxnet.io</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/kvstore_server/index.html">mxnet.kvstore_server</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/libinfo/index.html">mxnet.libinfo</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/log/index.html">mxnet.log</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/model/index.html">mxnet.model</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/monitor/index.html">mxnet.monitor</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/name/index.html">mxnet.name</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/notebook/index.html">mxnet.notebook</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/operator/index.html">mxnet.operator</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/profiler/index.html">mxnet.profiler</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/random/index.html">mxnet.random</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/recordio/index.html">mxnet.recordio</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/registry/index.html">mxnet.registry</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/rtc/index.html">mxnet.rtc</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/runtime/index.html">mxnet.runtime</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/test_utils/index.html">mxnet.test_utils</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/torch/index.html">mxnet.torch</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/util/index.html">mxnet.util</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mxnet/visualization/index.html">mxnet.visualization</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| |
| </nav> |
| |
| </div> |
| |
| </header> |
| |
| <div class="document"> |
| <div class="page-content" role="main"> |
| |
| <div class="section" id="module-mxnet.module"> |
| <span id="mxnet-module"></span><h1>mxnet.module<a class="headerlink" href="#module-mxnet.module" title="Permalink to this headline">¶</a></h1> |
| <p>A module is like a FeedForward model. But we would like to make it |
| easier to compose, similar to Torch modules.</p> |
| <p><strong>Classes</strong></p> |
| <table class="longtable docutils align-default"> |
| <colgroup> |
| <col style="width: 10%" /> |
| <col style="width: 90%" /> |
| </colgroup> |
| <tbody> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BaseModule" title="mxnet.module.BaseModule"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BaseModule</span></code></a>([logger])</p></td> |
| <td><p>The base class of a module.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule" title="mxnet.module.BucketingModule"><code class="xref py py-obj docutils literal notranslate"><span class="pre">BucketingModule</span></code></a>(sym_gen[, …])</p></td> |
| <td><p>This module helps to deal efficiently with varying-length inputs.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.Module" title="mxnet.module.Module"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Module</span></code></a>(symbol[, data_names, label_names, …])</p></td> |
| <td><p>Module is a basic module that wrap a <cite>Symbol</cite>.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.PythonLossModule" title="mxnet.module.PythonLossModule"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PythonLossModule</span></code></a>([name, data_names, …])</p></td> |
| <td><p>A convenient module class that implements many of the module APIs as empty functions.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.PythonModule" title="mxnet.module.PythonModule"><code class="xref py py-obj docutils literal notranslate"><span class="pre">PythonModule</span></code></a>(data_names, label_names, …[, …])</p></td> |
| <td><p>A convenient module class that implements many of the module APIs as empty functions.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.SequentialModule" title="mxnet.module.SequentialModule"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SequentialModule</span></code></a>([logger])</p></td> |
| <td><p>A SequentialModule is a container module that can chain multiple modules together.</p></td> |
| </tr> |
| </tbody> |
| </table> |
| <dl class="class"> |
| <dt id="mxnet.module.BaseModule"> |
| <em class="property">class </em><code class="sig-prename descclassname">mxnet.module.</code><code class="sig-name descname">BaseModule</code><span class="sig-paren">(</span><em class="sig-param">logger=<module 'logging' from '/work/conda_env/lib/python3.9/logging/__init__.py'></em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p> |
| <p>The base class of a module.</p> |
| <p>A module represents a computation component. One can think of module as a computation machine. |
| A module can execute forward and backward passes and update parameters in a model. |
| We aim to make the APIs easy to use, especially in the case when we need to use the imperative |
| API to work with multiple modules (e.g. stochastic depth network).</p> |
| <p>A module has several states:</p> |
| <ul class="simple"> |
| <li><p>Initial state: Memory is not allocated yet, so the module is not ready for computation yet.</p></li> |
| <li><p>Binded: Shapes for inputs, outputs, and parameters are all known, memory has been allocated, |
| and the module is ready for computation.</p></li> |
| <li><p>Parameters are initialized: For modules with parameters, doing computation before |
| initializing the parameters might result in undefined outputs.</p></li> |
| <li><p>Optimizer is installed: An optimizer can be installed to a module. After this, the parameters |
| of the module can be updated according to the optimizer after gradients are computed |
| (forward-backward).</p></li> |
| </ul> |
| <p><strong>Methods</strong></p> |
| <table class="longtable docutils align-default"> |
| <colgroup> |
| <col style="width: 10%" /> |
| <col style="width: 90%" /> |
| </colgroup> |
| <tbody> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.backward" title="mxnet.module.BaseModule.backward"><code class="xref py py-obj docutils literal notranslate"><span class="pre">backward</span></code></a>([out_grads])</p></td> |
| <td><p>Backward computation.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.bind" title="mxnet.module.BaseModule.bind"><code class="xref py py-obj docutils literal notranslate"><span class="pre">bind</span></code></a>(data_shapes[, label_shapes, …])</p></td> |
| <td><p>Binds the symbols to construct executors.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.fit" title="mxnet.module.BaseModule.fit"><code class="xref py py-obj docutils literal notranslate"><span class="pre">fit</span></code></a>(train_data[, eval_data, eval_metric, …])</p></td> |
| <td><p>Trains the module parameters.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.forward" title="mxnet.module.BaseModule.forward"><code class="xref py py-obj docutils literal notranslate"><span class="pre">forward</span></code></a>(data_batch[, is_train])</p></td> |
| <td><p>Forward computation.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.forward_backward" title="mxnet.module.BaseModule.forward_backward"><code class="xref py py-obj docutils literal notranslate"><span class="pre">forward_backward</span></code></a>(data_batch)</p></td> |
| <td><p>A convenient function that calls both <code class="docutils literal notranslate"><span class="pre">forward</span></code> and <code class="docutils literal notranslate"><span class="pre">backward</span></code>.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.get_input_grads" title="mxnet.module.BaseModule.get_input_grads"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_input_grads</span></code></a>([merge_multi_context])</p></td> |
| <td><p>Gets the gradients to the inputs, computed in the previous backward computation.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.get_outputs" title="mxnet.module.BaseModule.get_outputs"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_outputs</span></code></a>([merge_multi_context])</p></td> |
| <td><p>Gets outputs of the previous forward computation.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.get_params" title="mxnet.module.BaseModule.get_params"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_params</span></code></a>()</p></td> |
| <td><p>Gets parameters, those are potentially copies of the actual parameters used to do computation on the device.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.get_states" title="mxnet.module.BaseModule.get_states"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_states</span></code></a>([merge_multi_context])</p></td> |
| <td><p>Gets states from all devices</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.init_optimizer" title="mxnet.module.BaseModule.init_optimizer"><code class="xref py py-obj docutils literal notranslate"><span class="pre">init_optimizer</span></code></a>([kvstore, optimizer, …])</p></td> |
| <td><p>Installs and initializes optimizers, as well as initialize kvstore for</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.init_params" title="mxnet.module.BaseModule.init_params"><code class="xref py py-obj docutils literal notranslate"><span class="pre">init_params</span></code></a>([initializer, arg_params, …])</p></td> |
| <td><p>Initializes the parameters and auxiliary states.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.install_monitor" title="mxnet.module.BaseModule.install_monitor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">install_monitor</span></code></a>(mon)</p></td> |
| <td><p>Installs monitor on all executors.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.iter_predict" title="mxnet.module.BaseModule.iter_predict"><code class="xref py py-obj docutils literal notranslate"><span class="pre">iter_predict</span></code></a>(eval_data[, num_batch, reset, …])</p></td> |
| <td><p>Iterates over predictions.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.load_params" title="mxnet.module.BaseModule.load_params"><code class="xref py py-obj docutils literal notranslate"><span class="pre">load_params</span></code></a>(fname)</p></td> |
| <td><p>Loads model parameters from file.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.predict" title="mxnet.module.BaseModule.predict"><code class="xref py py-obj docutils literal notranslate"><span class="pre">predict</span></code></a>(eval_data[, num_batch, …])</p></td> |
| <td><p>Runs prediction and collects the outputs.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.prepare" title="mxnet.module.BaseModule.prepare"><code class="xref py py-obj docutils literal notranslate"><span class="pre">prepare</span></code></a>(data_batch[, sparse_row_id_fn])</p></td> |
| <td><p>Prepares the module for processing a data batch.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.save_params" title="mxnet.module.BaseModule.save_params"><code class="xref py py-obj docutils literal notranslate"><span class="pre">save_params</span></code></a>(fname)</p></td> |
| <td><p>Saves model parameters to file.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.score" title="mxnet.module.BaseModule.score"><code class="xref py py-obj docutils literal notranslate"><span class="pre">score</span></code></a>(eval_data, eval_metric[, num_batch, …])</p></td> |
| <td><p>Runs prediction on <code class="docutils literal notranslate"><span class="pre">eval_data</span></code> and evaluates the performance according to the given <code class="docutils literal notranslate"><span class="pre">eval_metric</span></code>.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.set_params" title="mxnet.module.BaseModule.set_params"><code class="xref py py-obj docutils literal notranslate"><span class="pre">set_params</span></code></a>(arg_params, aux_params[, …])</p></td> |
| <td><p>Assigns parameter and aux state values.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.set_states" title="mxnet.module.BaseModule.set_states"><code class="xref py py-obj docutils literal notranslate"><span class="pre">set_states</span></code></a>([states, value])</p></td> |
| <td><p>Sets value for states.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.update" title="mxnet.module.BaseModule.update"><code class="xref py py-obj docutils literal notranslate"><span class="pre">update</span></code></a>()</p></td> |
| <td><p>Updates parameters according to the installed optimizer and the gradients computed in the previous forward-backward batch.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.update_metric" title="mxnet.module.BaseModule.update_metric"><code class="xref py py-obj docutils literal notranslate"><span class="pre">update_metric</span></code></a>(eval_metric, labels[, pre_sliced])</p></td> |
| <td><p>Evaluates and accumulates evaluation metric on outputs of the last forward computation.</p></td> |
| </tr> |
| </tbody> |
| </table> |
| <p><strong>Attributes</strong></p> |
| <table class="longtable docutils align-default"> |
| <colgroup> |
| <col style="width: 10%" /> |
| <col style="width: 90%" /> |
| </colgroup> |
| <tbody> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.data_names" title="mxnet.module.BaseModule.data_names"><code class="xref py py-obj docutils literal notranslate"><span class="pre">data_names</span></code></a></p></td> |
| <td><p>A list of names for data required by this module.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.data_shapes" title="mxnet.module.BaseModule.data_shapes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">data_shapes</span></code></a></p></td> |
| <td><p>A list of (name, shape) pairs specifying the data inputs to this module.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.label_shapes" title="mxnet.module.BaseModule.label_shapes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">label_shapes</span></code></a></p></td> |
| <td><p>A list of (name, shape) pairs specifying the label inputs to this module.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.output_names" title="mxnet.module.BaseModule.output_names"><code class="xref py py-obj docutils literal notranslate"><span class="pre">output_names</span></code></a></p></td> |
| <td><p>A list of names for the outputs of this module.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.output_shapes" title="mxnet.module.BaseModule.output_shapes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">output_shapes</span></code></a></p></td> |
| <td><p>A list of (name, shape) pairs specifying the outputs of this module.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BaseModule.symbol" title="mxnet.module.BaseModule.symbol"><code class="xref py py-obj docutils literal notranslate"><span class="pre">symbol</span></code></a></p></td> |
| <td><p>Gets the symbol associated with this module.</p></td> |
| </tr> |
| </tbody> |
| </table> |
| <p>In order for a module to interact with others, it must be able to report the |
| following information in its initial state (before binding):</p> |
| <ul class="simple"> |
| <li><p><cite>data_names</cite>: list of type string indicating the names of the required input data.</p></li> |
| <li><p><cite>output_names</cite>: list of type string indicating the names of the required outputs.</p></li> |
| </ul> |
| <p>After binding, a module should be able to report the following richer information:</p> |
| <ul class="simple"> |
| <li><dl class="simple"> |
| <dt>state information</dt><dd><ul> |
| <li><p><cite>binded</cite>: <cite>bool</cite>, indicates whether the memory buffers needed for computation |
| have been allocated.</p></li> |
| <li><p><cite>for_training</cite>: whether the module is bound for training.</p></li> |
| <li><p><cite>params_initialized</cite>: <cite>bool</cite>, indicates whether the parameters of this module |
| have been initialized.</p></li> |
| <li><p><cite>optimizer_initialized</cite>: <cite>bool</cite>, indicates whether an optimizer is defined |
| and initialized.</p></li> |
| <li><p><cite>inputs_need_grad</cite>: <cite>bool</cite>, indicates whether gradients with respect to the |
| input data are needed. Might be useful when implementing composition of modules.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </li> |
| <li><dl class="simple"> |
| <dt>input/output information</dt><dd><ul> |
| <li><p><cite>data_shapes</cite>: a list of <cite>(name, shape)</cite>. In theory, since the memory is allocated, |
| we could directly provide the data arrays. But in the case of data parallelism, |
| the data arrays might not be of the same shape as viewed from the external world.</p></li> |
| <li><p><cite>label_shapes</cite>: a list of <cite>(name, shape)</cite>. This might be <cite>[]</cite> if the module does |
| not need labels (e.g. it does not contains a loss function at the top), or a module |
| is not bound for training.</p></li> |
| <li><p><cite>output_shapes</cite>: a list of <cite>(name, shape)</cite> for outputs of the module.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </li> |
| <li><dl class="simple"> |
| <dt>parameters (for modules with parameters)</dt><dd><ul> |
| <li><p><cite>get_params()</cite>: return a tuple <cite>(arg_params, aux_params)</cite>. Each of those |
| is a dictionary of name to <code class="docutils literal notranslate"><span class="pre">NDArray</span></code> mapping. Those <cite>NDArray</cite> always lives on |
| CPU. The actual parameters used for computing might live on other devices (GPUs), |
| this function will retrieve (a copy of) the latest parameters.</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">set_params(arg_params,</span> <span class="pre">aux_params)</span></code>: assign parameters to the devices |
| doing the computation.</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">init_params(...)</span></code>: a more flexible interface to assign or initialize the parameters.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </li> |
| <li><dl class="simple"> |
| <dt>setup</dt><dd><ul> |
| <li><p><cite>bind()</cite>: prepare environment for computation.</p></li> |
| <li><p><cite>init_optimizer()</cite>: install optimizer for parameter updating.</p></li> |
| <li><p><cite>prepare()</cite>: prepare the module based on the current data batch.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </li> |
| <li><dl class="simple"> |
| <dt>computation</dt><dd><ul> |
| <li><p><cite>forward(data_batch)</cite>: forward operation.</p></li> |
| <li><p><cite>backward(out_grads=None)</cite>: backward operation.</p></li> |
| <li><p><cite>update()</cite>: update parameters according to installed optimizer.</p></li> |
| <li><p><cite>get_outputs()</cite>: get outputs of the previous forward operation.</p></li> |
| <li><p><cite>get_input_grads()</cite>: get the gradients with respect to the inputs computed |
| in the previous backward operation.</p></li> |
| <li><p><cite>update_metric(metric, labels, pre_sliced=False)</cite>: update performance metric |
| for the previous forward |
| computed results.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </li> |
| <li><dl class="simple"> |
| <dt>other properties (mostly for backward compatibility)</dt><dd><ul> |
| <li><p><cite>symbol</cite>: the underlying symbolic graph for this module (if any) |
| This property is not necessarily constant. For example, for <cite>BucketingModule</cite>, |
| this property is simply the <em>current</em> symbol being used. For other modules, |
| this value might not be well defined.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </li> |
| </ul> |
| <p>When those intermediate-level API are implemented properly, the following |
| high-level API will be automatically available for a module:</p> |
| <ul class="simple"> |
| <li><p><cite>fit</cite>: train the module parameters on a data set.</p></li> |
| <li><p><cite>predict</cite>: run prediction on a data set and collect outputs.</p></li> |
| <li><p><cite>score</cite>: run prediction on a data set and evaluate performance.</p></li> |
| </ul> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of creating a mxnet module.</span> |
| <span class="gp">>>> </span><span class="kn">import</span> <span class="nn">mxnet</span> <span class="k">as</span> <span class="nn">mx</span> |
| <span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">symbol</span><span class="o">.</span><span class="n">Variable</span><span class="p">(</span><span class="s1">'data'</span><span class="p">)</span> |
| <span class="gp">>>> </span><span class="n">fc1</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">symbol</span><span class="o">.</span><span class="n">FullyConnected</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">'fc1'</span><span class="p">,</span> <span class="n">num_hidden</span><span class="o">=</span><span class="mi">128</span><span class="p">)</span> |
| <span class="gp">>>> </span><span class="n">act1</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">symbol</span><span class="o">.</span><span class="n">Activation</span><span class="p">(</span><span class="n">fc1</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">'relu1'</span><span class="p">,</span> <span class="n">act_type</span><span class="o">=</span><span class="s2">"relu"</span><span class="p">)</span> |
| <span class="gp">>>> </span><span class="n">fc2</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">symbol</span><span class="o">.</span><span class="n">FullyConnected</span><span class="p">(</span><span class="n">act1</span><span class="p">,</span> <span class="n">name</span> <span class="o">=</span> <span class="s1">'fc2'</span><span class="p">,</span> <span class="n">num_hidden</span> <span class="o">=</span> <span class="mi">64</span><span class="p">)</span> |
| <span class="gp">>>> </span><span class="n">act2</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">symbol</span><span class="o">.</span><span class="n">Activation</span><span class="p">(</span><span class="n">fc2</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">'relu2'</span><span class="p">,</span> <span class="n">act_type</span><span class="o">=</span><span class="s2">"relu"</span><span class="p">)</span> |
| <span class="gp">>>> </span><span class="n">fc3</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">symbol</span><span class="o">.</span><span class="n">FullyConnected</span><span class="p">(</span><span class="n">act2</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">'fc3'</span><span class="p">,</span> <span class="n">num_hidden</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span> |
| <span class="gp">>>> </span><span class="n">out</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">symbol</span><span class="o">.</span><span class="n">SoftmaxOutput</span><span class="p">(</span><span class="n">fc3</span><span class="p">,</span> <span class="n">name</span> <span class="o">=</span> <span class="s1">'softmax'</span><span class="p">)</span> |
| <span class="gp">>>> </span><span class="n">mod</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">mod</span><span class="o">.</span><span class="n">Module</span><span class="p">(</span><span class="n">out</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.backward"> |
| <code class="sig-name descname">backward</code><span class="sig-paren">(</span><em class="sig-param">out_grads=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.backward"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.backward" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Backward computation.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>out_grads</strong> (<a class="reference internal" href="../ndarray/ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a><em> or </em><em>list of NDArray</em><em>, </em><em>optional</em>) – Gradient on the outputs to be propagated back. |
| This parameter is only needed when bind is called |
| on outputs that are not a loss function.</p> |
| </dd> |
| </dl> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of backward computation.</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">backward</span><span class="p">()</span> |
| <span class="gp">>>> </span><span class="nb">print</span> <span class="n">mod</span><span class="o">.</span><span class="n">get_input_grads</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">asnumpy</span><span class="p">()</span> |
| <span class="go">[[[ 1.10182791e-05 5.12257748e-06 4.01927764e-06 8.32566820e-06</span> |
| <span class="go"> -1.59775993e-06 7.24269375e-06 7.28067835e-06 -1.65902311e-05</span> |
| <span class="go"> 5.46342608e-06 8.44196393e-07]</span> |
| <span class="go"> ...]]</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.bind"> |
| <code class="sig-name descname">bind</code><span class="sig-paren">(</span><em class="sig-param">data_shapes</em>, <em class="sig-param">label_shapes=None</em>, <em class="sig-param">for_training=True</em>, <em class="sig-param">inputs_need_grad=False</em>, <em class="sig-param">force_rebind=False</em>, <em class="sig-param">shared_module=None</em>, <em class="sig-param">grad_req='write'</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.bind"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.bind" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Binds the symbols to construct executors. This is necessary before one |
| can perform computation with the module.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>data_shapes</strong> (<em>list of</em><em> (</em><em>str</em><em>, </em><em>tuple</em><em>) or </em><em>DataDesc objects</em>) – Typically is <code class="docutils literal notranslate"><span class="pre">data_iter.provide_data</span></code>. Can also be a list of |
| (data name, data shape).</p></li> |
| <li><p><strong>label_shapes</strong> (<em>list of</em><em> (</em><em>str</em><em>, </em><em>tuple</em><em>) or </em><em>DataDesc objects</em>) – Typically is <code class="docutils literal notranslate"><span class="pre">data_iter.provide_label</span></code>. Can also be a list of |
| (label name, label shape).</p></li> |
| <li><p><strong>for_training</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">True</span></code>. Whether the executors should be bind for training.</p></li> |
| <li><p><strong>inputs_need_grad</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">False</span></code>. Whether the gradients to the input data need to be computed. |
| Typically this is not needed. But this might be needed when implementing composition |
| of modules.</p></li> |
| <li><p><strong>force_rebind</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">False</span></code>. This function does nothing if the executors are already |
| bound. But with this <code class="docutils literal notranslate"><span class="pre">True</span></code>, the executors will be forced to rebind.</p></li> |
| <li><p><strong>shared_module</strong> (<a class="reference internal" href="#mxnet.module.Module" title="mxnet.module.Module"><em>Module</em></a>) – Default is <code class="docutils literal notranslate"><span class="pre">None</span></code>. This is used in bucketing. When not <code class="docutils literal notranslate"><span class="pre">None</span></code>, the shared module |
| essentially corresponds to a different bucket – a module with different symbol |
| but with the same sets of parameters (e.g. unrolled RNNs with different lengths).</p></li> |
| <li><p><strong>grad_req</strong> (<em>str</em><em>, </em><em>list of str</em><em>, </em><em>dict of str to str</em>) – Requirement for gradient accumulation. Can be ‘write’, ‘add’, or ‘null’ |
| (default to ‘write’). |
| Can be specified globally (str) or for each argument (list, dict).</p></li> |
| </ul> |
| </dd> |
| </dl> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of binding symbols.</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">data_shapes</span><span class="o">=</span><span class="p">[(</span><span class="s1">'data'</span><span class="p">,</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">10</span><span class="p">))])</span> |
| <span class="gp">>>> </span><span class="c1"># Assume train_iter is already created.</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">data_shapes</span><span class="o">=</span><span class="n">train_iter</span><span class="o">.</span><span class="n">provide_data</span><span class="p">,</span> <span class="n">label_shapes</span><span class="o">=</span><span class="n">train_iter</span><span class="o">.</span><span class="n">provide_label</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.data_names"> |
| <em class="property">property </em><code class="sig-name descname">data_names</code><a class="headerlink" href="#mxnet.module.BaseModule.data_names" title="Permalink to this definition">¶</a></dt> |
| <dd><p>A list of names for data required by this module.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.data_shapes"> |
| <em class="property">property </em><code class="sig-name descname">data_shapes</code><a class="headerlink" href="#mxnet.module.BaseModule.data_shapes" title="Permalink to this definition">¶</a></dt> |
| <dd><p>A list of (name, shape) pairs specifying the data inputs to this module.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.fit"> |
| <code class="sig-name descname">fit</code><span class="sig-paren">(</span><em class="sig-param">train_data</em>, <em class="sig-param">eval_data=None</em>, <em class="sig-param">eval_metric='acc'</em>, <em class="sig-param">epoch_end_callback=None</em>, <em class="sig-param">batch_end_callback=None</em>, <em class="sig-param">kvstore='local'</em>, <em class="sig-param">optimizer='sgd'</em>, <em class="sig-param">optimizer_params=(('learning_rate'</em>, <em class="sig-param">0.01)</em>, <em class="sig-param">)</em>, <em class="sig-param">eval_end_callback=None</em>, <em class="sig-param">eval_batch_end_callback=None</em>, <em class="sig-param">initializer=<mxnet.initializer.Uniform object></em>, <em class="sig-param">arg_params=None</em>, <em class="sig-param">aux_params=None</em>, <em class="sig-param">allow_missing=False</em>, <em class="sig-param">force_rebind=False</em>, <em class="sig-param">force_init=False</em>, <em class="sig-param">begin_epoch=0</em>, <em class="sig-param">num_epoch=None</em>, <em class="sig-param">validation_metric=None</em>, <em class="sig-param">monitor=None</em>, <em class="sig-param">sparse_row_id_fn=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.fit"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.fit" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Trains the module parameters.</p> |
| <p>Checkout <a class="reference external" href="https://mxnet.apache.org/api/python/tutorials/packages/module/index.html">Module Tutorial</a> |
| to see an end-to-end use-case.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>train_data</strong> (<a class="reference internal" href="../mxnet/io/index.html#mxnet.io.DataIter" title="mxnet.io.DataIter"><em>DataIter</em></a>) – Train DataIter.</p></li> |
| <li><p><strong>eval_data</strong> (<a class="reference internal" href="../mxnet/io/index.html#mxnet.io.DataIter" title="mxnet.io.DataIter"><em>DataIter</em></a>) – If not <code class="docutils literal notranslate"><span class="pre">None</span></code>, will be used as validation set and the performance |
| after each epoch will be evaluated.</p></li> |
| <li><p><strong>eval_metric</strong> (<em>str</em><em> or </em><a class="reference internal" href="../metric/index.html#mxnet.metric.EvalMetric" title="mxnet.metric.EvalMetric"><em>EvalMetric</em></a>) – Defaults to ‘accuracy’. The performance measure used to display during training. |
| Other possible predefined metrics are: |
| ‘ce’ (CrossEntropy), ‘f1’, ‘mae’, ‘mse’, ‘rmse’, ‘top_k_accuracy’.</p></li> |
| <li><p><strong>epoch_end_callback</strong> (<em>function</em><em> or </em><em>list of functions</em>) – Each callback will be called with the current <cite>epoch</cite>, <cite>symbol</cite>, <cite>arg_params</cite> |
| and <cite>aux_params</cite>.</p></li> |
| <li><p><strong>batch_end_callback</strong> (<em>function</em><em> or </em><em>list of function</em>) – Each callback will be called with a <cite>BatchEndParam</cite>.</p></li> |
| <li><p><strong>kvstore</strong> (<em>str</em><em> or </em><em>KVStore</em>) – Defaults to ‘local’.</p></li> |
| <li><p><strong>optimizer</strong> (<em>str</em><em> or </em><a class="reference internal" href="../optimizer/index.html#mxnet.optimizer.Optimizer" title="mxnet.optimizer.Optimizer"><em>Optimizer</em></a>) – Defaults to ‘sgd’.</p></li> |
| <li><p><strong>optimizer_params</strong> (<em>dict</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">(('learning_rate',</span> <span class="pre">0.01),)</span></code>. The parameters for |
| the optimizer constructor. |
| The default value is not a dict, just to avoid pylint warning on dangerous |
| default values.</p></li> |
| <li><p><strong>eval_end_callback</strong> (<em>function</em><em> or </em><em>list of function</em>) – These will be called at the end of each full evaluation, with the metrics over |
| the entire evaluation set.</p></li> |
| <li><p><strong>eval_batch_end_callback</strong> (<em>function</em><em> or </em><em>list of function</em>) – These will be called at the end of each mini-batch during evaluation.</p></li> |
| <li><p><strong>initializer</strong> (<a class="reference internal" href="../initializer/index.html#mxnet.initializer.Initializer" title="mxnet.initializer.Initializer"><em>Initializer</em></a>) – The initializer is called to initialize the module parameters when they are |
| not already initialized.</p></li> |
| <li><p><strong>arg_params</strong> (<em>dict</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">None</span></code>, if not <code class="docutils literal notranslate"><span class="pre">None</span></code>, should be existing parameters from a trained |
| model or loaded from a checkpoint (previously saved model). In this case, |
| the value here will be used to initialize the module parameters, unless they |
| are already initialized by the user via a call to <cite>init_params</cite> or <cite>fit</cite>. |
| <cite>arg_params</cite> has a higher priority than <cite>initializer</cite>.</p></li> |
| <li><p><strong>aux_params</strong> (<em>dict</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">None</span></code>. Similar to <cite>arg_params</cite>, except for auxiliary states.</p></li> |
| <li><p><strong>allow_missing</strong> (<em>bool</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">False</span></code>. Indicates whether to allow missing parameters when <cite>arg_params</cite> |
| and <cite>aux_params</cite> are not <code class="docutils literal notranslate"><span class="pre">None</span></code>. If this is <code class="docutils literal notranslate"><span class="pre">True</span></code>, then the missing parameters |
| will be initialized via the <cite>initializer</cite>.</p></li> |
| <li><p><strong>force_rebind</strong> (<em>bool</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">False</span></code>. Whether to force rebinding the executors if already bound.</p></li> |
| <li><p><strong>force_init</strong> (<em>bool</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">False</span></code>. Indicates whether to force initialization even if the |
| parameters are already initialized.</p></li> |
| <li><p><strong>begin_epoch</strong> (<em>int</em>) – Defaults to 0. Indicates the starting epoch. Usually, if resumed from a |
| checkpoint saved at a previous training phase at epoch N, then this value should be |
| N+1.</p></li> |
| <li><p><strong>num_epoch</strong> (<em>int</em>) – Number of epochs for training.</p></li> |
| <li><p><strong>sparse_row_id_fn</strong> (<em>A callback function</em>) – The function takes <cite>data_batch</cite> as an input and returns a dict of |
| str -> NDArray. The resulting dict is used for pulling row_sparse |
| parameters from the kvstore, where the str key is the name of the param, |
| and the value is the row id of the param to pull.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of using fit for training.</span> |
| <span class="gp">>>> </span><span class="c1"># Assume training dataIter and validation dataIter are ready</span> |
| <span class="gp">>>> </span><span class="c1"># Assume loading a previously checkpointed model</span> |
| <span class="gp">>>> </span><span class="n">sym</span><span class="p">,</span> <span class="n">arg_params</span><span class="p">,</span> <span class="n">aux_params</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">model</span><span class="o">.</span><span class="n">load_checkpoint</span><span class="p">(</span><span class="n">model_prefix</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="n">train_data</span><span class="o">=</span><span class="n">train_dataiter</span><span class="p">,</span> <span class="n">eval_data</span><span class="o">=</span><span class="n">val_dataiter</span><span class="p">,</span> <span class="n">optimizer</span><span class="o">=</span><span class="s1">'sgd'</span><span class="p">,</span> |
| <span class="gp">... </span> <span class="n">optimizer_params</span><span class="o">=</span><span class="p">{</span><span class="s1">'learning_rate'</span><span class="p">:</span><span class="mf">0.01</span><span class="p">,</span> <span class="s1">'momentum'</span><span class="p">:</span> <span class="mf">0.9</span><span class="p">},</span> |
| <span class="gp">... </span> <span class="n">arg_params</span><span class="o">=</span><span class="n">arg_params</span><span class="p">,</span> <span class="n">aux_params</span><span class="o">=</span><span class="n">aux_params</span><span class="p">,</span> |
| <span class="gp">... </span> <span class="n">eval_metric</span><span class="o">=</span><span class="s1">'acc'</span><span class="p">,</span> <span class="n">num_epoch</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">begin_epoch</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.forward"> |
| <code class="sig-name descname">forward</code><span class="sig-paren">(</span><em class="sig-param">data_batch</em>, <em class="sig-param">is_train=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.forward"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.forward" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Forward computation. It supports data batches with different shapes, such as |
| different batch sizes or different image sizes. |
| If reshaping of data batch relates to modification of symbol or module, such as |
| changing image layout ordering or switching from training to predicting, module |
| rebinding is required.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>data_batch</strong> (<a class="reference internal" href="../mxnet/io/index.html#mxnet.io.DataBatch" title="mxnet.io.DataBatch"><em>DataBatch</em></a>) – Could be anything with similar API implemented.</p></li> |
| <li><p><strong>is_train</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">None</span></code>, which means <cite>is_train</cite> takes the value of <code class="docutils literal notranslate"><span class="pre">self.for_training</span></code>.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">mxnet</span> <span class="k">as</span> <span class="nn">mx</span> |
| <span class="gp">>>> </span><span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">namedtuple</span> |
| <span class="gp">>>> </span><span class="n">Batch</span> <span class="o">=</span> <span class="n">namedtuple</span><span class="p">(</span><span class="s1">'Batch'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'data'</span><span class="p">])</span> |
| <span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">sym</span><span class="o">.</span><span class="n">Variable</span><span class="p">(</span><span class="s1">'data'</span><span class="p">)</span> |
| <span class="gp">>>> </span><span class="n">out</span> <span class="o">=</span> <span class="n">data</span> <span class="o">*</span> <span class="mi">2</span> |
| <span class="gp">>>> </span><span class="n">mod</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">mod</span><span class="o">.</span><span class="n">Module</span><span class="p">(</span><span class="n">symbol</span><span class="o">=</span><span class="n">out</span><span class="p">,</span> <span class="n">label_names</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">bind</span><span class="p">(</span><span class="n">data_shapes</span><span class="o">=</span><span class="p">[(</span><span class="s1">'data'</span><span class="p">,</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">))])</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">init_params</span><span class="p">()</span> |
| <span class="gp">>>> </span><span class="n">data1</span> <span class="o">=</span> <span class="p">[</span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">ones</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">))]</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="n">Batch</span><span class="p">(</span><span class="n">data1</span><span class="p">))</span> |
| <span class="gp">>>> </span><span class="nb">print</span> <span class="n">mod</span><span class="o">.</span><span class="n">get_outputs</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">asnumpy</span><span class="p">()</span> |
| <span class="go">[[ 2. 2. 2. 2. 2. 2. 2. 2. 2. 2.]]</span> |
| <span class="gp">>>> </span><span class="c1"># Forward with data batch of different shape</span> |
| <span class="gp">>>> </span><span class="n">data2</span> <span class="o">=</span> <span class="p">[</span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">ones</span><span class="p">((</span><span class="mi">3</span><span class="p">,</span> <span class="mi">5</span><span class="p">))]</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="n">Batch</span><span class="p">(</span><span class="n">data2</span><span class="p">))</span> |
| <span class="gp">>>> </span><span class="nb">print</span> <span class="n">mod</span><span class="o">.</span><span class="n">get_outputs</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">asnumpy</span><span class="p">()</span> |
| <span class="go">[[ 2. 2. 2. 2. 2.]</span> |
| <span class="go"> [ 2. 2. 2. 2. 2.]</span> |
| <span class="go"> [ 2. 2. 2. 2. 2.]]</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.forward_backward"> |
| <code class="sig-name descname">forward_backward</code><span class="sig-paren">(</span><em class="sig-param">data_batch</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.forward_backward"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.forward_backward" title="Permalink to this definition">¶</a></dt> |
| <dd><p>A convenient function that calls both <code class="docutils literal notranslate"><span class="pre">forward</span></code> and <code class="docutils literal notranslate"><span class="pre">backward</span></code>.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.get_input_grads"> |
| <code class="sig-name descname">get_input_grads</code><span class="sig-paren">(</span><em class="sig-param">merge_multi_context=True</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.get_input_grads"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.get_input_grads" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets the gradients to the inputs, computed in the previous backward computation.</p> |
| <p>If <cite>merge_multi_context</cite> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, it is like <code class="docutils literal notranslate"><span class="pre">[grad1,</span> <span class="pre">grad2]</span></code>. Otherwise, it |
| is like <code class="docutils literal notranslate"><span class="pre">[[grad1_dev1,</span> <span class="pre">grad1_dev2],</span> <span class="pre">[grad2_dev1,</span> <span class="pre">grad2_dev2]]</span></code>. All the output |
| elements have type <cite>NDArray</cite>. When <cite>merge_multi_context</cite> is <code class="docutils literal notranslate"><span class="pre">False</span></code>, those <cite>NDArray</cite> |
| instances might live on different devices.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>merge_multi_context</strong> (<em>bool</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">True</span></code>. In the case when data-parallelism is used, the gradients |
| will be collected from multiple devices. A <code class="docutils literal notranslate"><span class="pre">True</span></code> value indicates that we |
| should merge the collected results so that they look like from a single |
| executor.</p> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Input gradients.</p> |
| </dd> |
| <dt class="field-odd">Return type</dt> |
| <dd class="field-odd"><p>list of NDArray or list of list of NDArray</p> |
| </dd> |
| </dl> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of getting input gradients.</span> |
| <span class="gp">>>> </span><span class="nb">print</span> <span class="n">mod</span><span class="o">.</span><span class="n">get_input_grads</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">asnumpy</span><span class="p">()</span> |
| <span class="go">[[[ 1.10182791e-05 5.12257748e-06 4.01927764e-06 8.32566820e-06</span> |
| <span class="go"> -1.59775993e-06 7.24269375e-06 7.28067835e-06 -1.65902311e-05</span> |
| <span class="go"> 5.46342608e-06 8.44196393e-07]</span> |
| <span class="go"> ...]]</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.get_outputs"> |
| <code class="sig-name descname">get_outputs</code><span class="sig-paren">(</span><em class="sig-param">merge_multi_context=True</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.get_outputs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.get_outputs" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets outputs of the previous forward computation.</p> |
| <p>If <cite>merge_multi_context</cite> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, it is like <code class="docutils literal notranslate"><span class="pre">[out1,</span> <span class="pre">out2]</span></code>. Otherwise, |
| it returns out put of form <code class="docutils literal notranslate"><span class="pre">[[out1_dev1,</span> <span class="pre">out1_dev2],</span> <span class="pre">[out2_dev1,</span> <span class="pre">out2_dev2]]</span></code>. |
| All the output elements have type <cite>NDArray</cite>. When <cite>merge_multi_context</cite> is <code class="docutils literal notranslate"><span class="pre">False</span></code>, |
| those <cite>NDArray</cite> instances might live on different devices.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>merge_multi_context</strong> (<em>bool</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">True</span></code>. In the case when data-parallelism is used, the outputs |
| will be collected from multiple devices. A <code class="docutils literal notranslate"><span class="pre">True</span></code> value indicates that we |
| should merge the collected results so that they look like from a single |
| executor.</p> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Output</p> |
| </dd> |
| <dt class="field-odd">Return type</dt> |
| <dd class="field-odd"><p>list of <cite>NDArray</cite> or list of list of <cite>NDArray</cite>.</p> |
| </dd> |
| </dl> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of getting forward output.</span> |
| <span class="gp">>>> </span><span class="nb">print</span> <span class="n">mod</span><span class="o">.</span><span class="n">get_outputs</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">asnumpy</span><span class="p">()</span> |
| <span class="go">[[ 0.09999977 0.10000153 0.10000716 0.10000195 0.09999853 0.09999743</span> |
| <span class="go"> 0.10000272 0.10000113 0.09999088 0.09999888]]</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.get_params"> |
| <code class="sig-name descname">get_params</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.get_params"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.get_params" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets parameters, those are potentially copies of the actual parameters used |
| to do computation on the device.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Returns</dt> |
| <dd class="field-odd"><p>A pair of dictionaries each mapping parameter names to NDArray values.</p> |
| </dd> |
| <dt class="field-even">Return type</dt> |
| <dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">(arg_params,</span> <span class="pre">aux_params)</span></code></p> |
| </dd> |
| </dl> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of getting module parameters.</span> |
| <span class="gp">>>> </span><span class="nb">print</span> <span class="n">mod</span><span class="o">.</span><span class="n">get_params</span><span class="p">()</span> |
| <span class="go">({'fc2_weight': <NDArray 64x128 @cpu(0)>, 'fc1_weight': <NDArray 128x100 @cpu(0)>,</span> |
| <span class="go">'fc3_bias': <NDArray 10 @cpu(0)>, 'fc3_weight': <NDArray 10x64 @cpu(0)>,</span> |
| <span class="go">'fc2_bias': <NDArray 64 @cpu(0)>, 'fc1_bias': <NDArray 128 @cpu(0)>}, {})</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.get_states"> |
| <code class="sig-name descname">get_states</code><span class="sig-paren">(</span><em class="sig-param">merge_multi_context=True</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.get_states"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.get_states" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets states from all devices</p> |
| <p>If <cite>merge_multi_context</cite> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, returns output of form <code class="docutils literal notranslate"><span class="pre">[out1,</span> <span class="pre">out2]</span></code>. |
| Otherwise, it returns output of the form |
| <code class="docutils literal notranslate"><span class="pre">[[out1_dev1,</span> <span class="pre">out1_dev2],</span> <span class="pre">[out2_dev1,</span> <span class="pre">out2_dev2]]</span></code>. |
| All output elements are <cite>NDArray</cite>.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>merge_multi_context</strong> (<em>bool</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">True</span></code>. In the case when data-parallelism is used, the states |
| will be collected from multiple devices. A <code class="docutils literal notranslate"><span class="pre">True</span></code> value indicates that we |
| should merge the collected results so that they look like from a single |
| executor.</p> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p></p> |
| </dd> |
| <dt class="field-odd">Return type</dt> |
| <dd class="field-odd"><p>A list of <code class="docutils literal notranslate"><span class="pre">NDArray</span></code> or a list of list of <code class="docutils literal notranslate"><span class="pre">NDArray</span></code>.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.init_optimizer"> |
| <code class="sig-name descname">init_optimizer</code><span class="sig-paren">(</span><em class="sig-param">kvstore='local'</em>, <em class="sig-param">optimizer='sgd'</em>, <em class="sig-param">optimizer_params=(('learning_rate'</em>, <em class="sig-param">0.01)</em>, <em class="sig-param">)</em>, <em class="sig-param">force_init=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.init_optimizer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.init_optimizer" title="Permalink to this definition">¶</a></dt> |
| <dd><dl class="simple"> |
| <dt>Installs and initializes optimizers, as well as initialize kvstore for</dt><dd><p>distributed training</p> |
| </dd> |
| </dl> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>kvstore</strong> (<em>str</em><em> or </em><em>KVStore</em>) – Defaults to <cite>‘local’</cite>.</p></li> |
| <li><p><strong>optimizer</strong> (<em>str</em><em> or </em><a class="reference internal" href="../optimizer/index.html#mxnet.optimizer.Optimizer" title="mxnet.optimizer.Optimizer"><em>Optimizer</em></a>) – Defaults to <cite>‘sgd’</cite>.</p></li> |
| <li><p><strong>optimizer_params</strong> (<em>dict</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">(('learning_rate',</span> <span class="pre">0.01),)</span></code>. The default value is not a dictionary, |
| just to avoid pylint warning of dangerous default values.</p></li> |
| <li><p><strong>force_init</strong> (<em>bool</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">False</span></code>, indicates whether to force re-initializing an optimizer |
| if it is already installed.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of initializing optimizer.</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">init_optimizer</span><span class="p">(</span><span class="n">optimizer</span><span class="o">=</span><span class="s1">'sgd'</span><span class="p">,</span> <span class="n">optimizer_params</span><span class="o">=</span><span class="p">((</span><span class="s1">'learning_rate'</span><span class="p">,</span> <span class="mf">0.005</span><span class="p">),))</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.init_params"> |
| <code class="sig-name descname">init_params</code><span class="sig-paren">(</span><em class="sig-param">initializer=<mxnet.initializer.Uniform object></em>, <em class="sig-param">arg_params=None</em>, <em class="sig-param">aux_params=None</em>, <em class="sig-param">allow_missing=False</em>, <em class="sig-param">force_init=False</em>, <em class="sig-param">allow_extra=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.init_params"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.init_params" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Initializes the parameters and auxiliary states.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>initializer</strong> (<a class="reference internal" href="../initializer/index.html#mxnet.initializer.Initializer" title="mxnet.initializer.Initializer"><em>Initializer</em></a>) – Called to initialize parameters if needed.</p></li> |
| <li><p><strong>arg_params</strong> (<em>dict</em>) – If not <code class="docutils literal notranslate"><span class="pre">None</span></code>, should be a dictionary of existing <cite>arg_params</cite>. Initialization |
| will be copied from that.</p></li> |
| <li><p><strong>aux_params</strong> (<em>dict</em>) – If not <code class="docutils literal notranslate"><span class="pre">None</span></code>, should be a dictionary of existing <cite>aux_params</cite>. Initialization |
| will be copied from that.</p></li> |
| <li><p><strong>allow_missing</strong> (<em>bool</em>) – If <code class="docutils literal notranslate"><span class="pre">True</span></code>, params could contain missing values, and the initializer will be |
| called to fill those missing params.</p></li> |
| <li><p><strong>force_init</strong> (<em>bool</em>) – If <code class="docutils literal notranslate"><span class="pre">True</span></code>, <cite>force_init</cite> will force re-initialize even if already initialized.</p></li> |
| <li><p><strong>allow_extra</strong> (<em>boolean</em><em>, </em><em>optional</em>) – Whether allow extra parameters that are not needed by symbol. |
| If this is True, no error will be thrown when arg_params or aux_params |
| contain extra parameters that is not needed by the executor.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of initializing module parameters.</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">init_params</span><span class="p">()</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.install_monitor"> |
| <code class="sig-name descname">install_monitor</code><span class="sig-paren">(</span><em class="sig-param">mon</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.install_monitor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.install_monitor" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Installs monitor on all executors.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.iter_predict"> |
| <code class="sig-name descname">iter_predict</code><span class="sig-paren">(</span><em class="sig-param">eval_data</em>, <em class="sig-param">num_batch=None</em>, <em class="sig-param">reset=True</em>, <em class="sig-param">sparse_row_id_fn=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.iter_predict"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.iter_predict" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Iterates over predictions.</p> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">for</span> <span class="n">pred</span><span class="p">,</span> <span class="n">i_batch</span><span class="p">,</span> <span class="n">batch</span> <span class="ow">in</span> <span class="n">module</span><span class="o">.</span><span class="n">iter_predict</span><span class="p">(</span><span class="n">eval_data</span><span class="p">):</span> |
| <span class="gp">... </span> <span class="c1"># pred is a list of outputs from the module</span> |
| <span class="gp">... </span> <span class="c1"># i_batch is a integer</span> |
| <span class="gp">... </span> <span class="c1"># batch is the data batch from the data iterator</span> |
| </pre></div> |
| </div> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>eval_data</strong> (<a class="reference internal" href="../mxnet/io/index.html#mxnet.io.DataIter" title="mxnet.io.DataIter"><em>DataIter</em></a>) – Evaluation data to run prediction on.</p></li> |
| <li><p><strong>num_batch</strong> (<em>int</em>) – Default is <code class="docutils literal notranslate"><span class="pre">None</span></code>, indicating running all the batches in the data iterator.</p></li> |
| <li><p><strong>reset</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">True</span></code>, indicating whether we should reset the data iter before start |
| doing prediction.</p></li> |
| <li><p><strong>sparse_row_id_fn</strong> (<em>A callback function</em>) – The function takes <cite>data_batch</cite> as an input and returns a dict of |
| str -> NDArray. The resulting dict is used for pulling row_sparse |
| parameters from the kvstore, where the str key is the name of the param, |
| and the value is the row id of the param to pull.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.label_shapes"> |
| <em class="property">property </em><code class="sig-name descname">label_shapes</code><a class="headerlink" href="#mxnet.module.BaseModule.label_shapes" title="Permalink to this definition">¶</a></dt> |
| <dd><p>A list of (name, shape) pairs specifying the label inputs to this module. |
| If this module does not accept labels – either it is a module without loss |
| function, or it is not bound for training, then this should return an empty |
| list <code class="docutils literal notranslate"><span class="pre">[]</span></code>.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.load_params"> |
| <code class="sig-name descname">load_params</code><span class="sig-paren">(</span><em class="sig-param">fname</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.load_params"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.load_params" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Loads model parameters from file.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>fname</strong> (<em>str</em>) – Path to input param file.</p> |
| </dd> |
| </dl> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of loading module parameters.</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">load_params</span><span class="p">(</span><span class="s1">'myfile'</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.output_names"> |
| <em class="property">property </em><code class="sig-name descname">output_names</code><a class="headerlink" href="#mxnet.module.BaseModule.output_names" title="Permalink to this definition">¶</a></dt> |
| <dd><p>A list of names for the outputs of this module.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.output_shapes"> |
| <em class="property">property </em><code class="sig-name descname">output_shapes</code><a class="headerlink" href="#mxnet.module.BaseModule.output_shapes" title="Permalink to this definition">¶</a></dt> |
| <dd><p>A list of (name, shape) pairs specifying the outputs of this module.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.predict"> |
| <code class="sig-name descname">predict</code><span class="sig-paren">(</span><em class="sig-param">eval_data</em>, <em class="sig-param">num_batch=None</em>, <em class="sig-param">merge_batches=True</em>, <em class="sig-param">reset=True</em>, <em class="sig-param">always_output_list=False</em>, <em class="sig-param">sparse_row_id_fn=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.predict"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.predict" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Runs prediction and collects the outputs.</p> |
| <p>When <cite>merge_batches</cite> is <code class="docutils literal notranslate"><span class="pre">True</span></code> (by default), the return value will be a list |
| <code class="docutils literal notranslate"><span class="pre">[out1,</span> <span class="pre">out2,</span> <span class="pre">out3]</span></code>, where each element is formed by concatenating the outputs for |
| all the mini-batches. When <cite>always_output_list</cite> is <code class="docutils literal notranslate"><span class="pre">False</span></code> (as by default), |
| then in the case of a single output, <cite>out1</cite> is returned instead of <code class="docutils literal notranslate"><span class="pre">[out1]</span></code>.</p> |
| <p>When <cite>merge_batches</cite> is <code class="docutils literal notranslate"><span class="pre">False</span></code>, the return value will be a nested list like |
| <code class="docutils literal notranslate"><span class="pre">[[out1_batch1,</span> <span class="pre">out2_batch1],</span> <span class="pre">[out1_batch2],</span> <span class="pre">...]</span></code>. This mode is useful because |
| in some cases (e.g. bucketing), the module does not necessarily produce the same |
| number of outputs.</p> |
| <p>The objects in the results have type <cite>NDArray</cite>. If you need to work with a numpy array, |
| just call <code class="docutils literal notranslate"><span class="pre">.asnumpy()</span></code> on each <cite>NDArray</cite>.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>eval_data</strong> (<a class="reference internal" href="../mxnet/io/index.html#mxnet.io.DataIter" title="mxnet.io.DataIter"><em>DataIter</em></a><em> or </em><a class="reference internal" href="../ndarray/ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a><em> or </em><em>numpy array</em>) – Evaluation data to run prediction on.</p></li> |
| <li><p><strong>num_batch</strong> (<em>int</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">None</span></code>, indicates running all the batches in the data iterator.</p></li> |
| <li><p><strong>merge_batches</strong> (<em>bool</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">True</span></code>, see above for return values.</p></li> |
| <li><p><strong>reset</strong> (<em>bool</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">True</span></code>, indicates whether we should reset the data iter before |
| doing prediction.</p></li> |
| <li><p><strong>always_output_list</strong> (<em>bool</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">False</span></code>, see above for return values.</p></li> |
| <li><p><strong>sparse_row_id_fn</strong> (<em>A callback function</em>) – The function takes <cite>data_batch</cite> as an input and returns a dict of |
| str -> NDArray. The resulting dict is used for pulling row_sparse |
| parameters from the kvstore, where the str key is the name of the param, |
| and the value is the row id of the param to pull.</p></li> |
| </ul> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Prediction results.</p> |
| </dd> |
| <dt class="field-odd">Return type</dt> |
| <dd class="field-odd"><p>list of NDArray or list of list of NDArray</p> |
| </dd> |
| </dl> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of using `predict` for prediction.</span> |
| <span class="gp">>>> </span><span class="c1"># Predict on the first 10 batches of val_dataiter</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">predict</span><span class="p">(</span><span class="n">eval_data</span><span class="o">=</span><span class="n">val_dataiter</span><span class="p">,</span> <span class="n">num_batch</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.prepare"> |
| <code class="sig-name descname">prepare</code><span class="sig-paren">(</span><em class="sig-param">data_batch</em>, <em class="sig-param">sparse_row_id_fn=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.prepare"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.prepare" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Prepares the module for processing a data batch.</p> |
| <p>Usually involves switching bucket and reshaping. |
| For modules that contain <cite>row_sparse</cite> parameters in KVStore, |
| it prepares the <cite>row_sparse</cite> parameters based on the sparse_row_id_fn.</p> |
| <p>When KVStore is used to update parameters for multi-device or multi-machine training, |
| a copy of the parameters are stored in KVStore. Note that for <cite>row_sparse</cite> parameters, |
| the <cite>update()</cite> updates the copy of parameters in KVStore, but doesn’t broadcast |
| the updated parameters to all devices / machines. The <cite>prepare</cite> function is used to |
| broadcast <cite>row_sparse</cite> parameters with the next batch of data.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>data_batch</strong> (<a class="reference internal" href="../mxnet/io/index.html#mxnet.io.DataBatch" title="mxnet.io.DataBatch"><em>DataBatch</em></a>) – The current batch of data for forward computation.</p></li> |
| <li><p><strong>sparse_row_id_fn</strong> (<em>A callback function</em>) – The function takes <cite>data_batch</cite> as an input and returns a dict of |
| str -> NDArray. The resulting dict is used for pulling row_sparse |
| parameters from the kvstore, where the str key is the name of the param, |
| and the value is the row id of the param to pull.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.save_params"> |
| <code class="sig-name descname">save_params</code><span class="sig-paren">(</span><em class="sig-param">fname</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.save_params"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.save_params" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Saves model parameters to file.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>fname</strong> (<em>str</em>) – Path to output param file.</p> |
| </dd> |
| </dl> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of saving module parameters.</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">save_params</span><span class="p">(</span><span class="s1">'myfile'</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.score"> |
| <code class="sig-name descname">score</code><span class="sig-paren">(</span><em class="sig-param">eval_data</em>, <em class="sig-param">eval_metric</em>, <em class="sig-param">num_batch=None</em>, <em class="sig-param">batch_end_callback=None</em>, <em class="sig-param">score_end_callback=None</em>, <em class="sig-param">reset=True</em>, <em class="sig-param">epoch=0</em>, <em class="sig-param">sparse_row_id_fn=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.score"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.score" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Runs prediction on <code class="docutils literal notranslate"><span class="pre">eval_data</span></code> and evaluates the performance according to |
| the given <code class="docutils literal notranslate"><span class="pre">eval_metric</span></code>.</p> |
| <p>Checkout <a class="reference external" href="https://mxnet.apache.org/api/python/tutorials/packages/module/index.html">Module Tutorial</a> |
| to see an end-to-end use-case.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>eval_data</strong> (<a class="reference internal" href="../mxnet/io/index.html#mxnet.io.DataIter" title="mxnet.io.DataIter"><em>DataIter</em></a>) – Evaluation data to run prediction on.</p></li> |
| <li><p><strong>eval_metric</strong> (<a class="reference internal" href="../metric/index.html#mxnet.metric.EvalMetric" title="mxnet.metric.EvalMetric"><em>EvalMetric</em></a><em> or </em><em>list of EvalMetrics</em>) – Evaluation metric to use.</p></li> |
| <li><p><strong>num_batch</strong> (<em>int</em>) – Number of batches to run. Defaults to <code class="docutils literal notranslate"><span class="pre">None</span></code>, indicating run until the <cite>DataIter</cite> |
| finishes.</p></li> |
| <li><p><strong>batch_end_callback</strong> (<em>function</em>) – Could also be a list of functions.</p></li> |
| <li><p><strong>reset</strong> (<em>bool</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">True</span></code>. Indicates whether we should reset <cite>eval_data</cite> before starting |
| evaluating.</p></li> |
| <li><p><strong>epoch</strong> (<em>int</em>) – Defaults to 0. For compatibility, this will be passed to callbacks (if any). |
| During training, this will correspond to the training epoch number.</p></li> |
| <li><p><strong>sparse_row_id_fn</strong> (<em>A callback function</em>) – The function takes <cite>data_batch</cite> as an input and returns a dict of |
| str -> NDArray. The resulting dict is used for pulling row_sparse |
| parameters from the kvstore, where the str key is the name of the param, |
| and the value is the row id of the param to pull.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of using score for prediction.</span> |
| <span class="gp">>>> </span><span class="c1"># Evaluate accuracy on val_dataiter</span> |
| <span class="gp">>>> </span><span class="n">metric</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">metric</span><span class="o">.</span><span class="n">Accuracy</span><span class="p">()</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">score</span><span class="p">(</span><span class="n">val_dataiter</span><span class="p">,</span> <span class="n">metric</span><span class="p">)</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">score</span><span class="p">(</span><span class="n">val_dataiter</span><span class="p">,</span> <span class="p">[</span><span class="s1">'mse'</span><span class="p">,</span> <span class="s1">'acc'</span><span class="p">])</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.set_params"> |
| <code class="sig-name descname">set_params</code><span class="sig-paren">(</span><em class="sig-param">arg_params</em>, <em class="sig-param">aux_params</em>, <em class="sig-param">allow_missing=False</em>, <em class="sig-param">force_init=True</em>, <em class="sig-param">allow_extra=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.set_params"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.set_params" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Assigns parameter and aux state values.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>arg_params</strong> (<em>dict</em>) – Dictionary of name to value (<cite>NDArray</cite>) mapping.</p></li> |
| <li><p><strong>aux_params</strong> (<em>dict</em>) – Dictionary of name to value (<cite>NDArray</cite>) mapping.</p></li> |
| <li><p><strong>allow_missing</strong> (<em>bool</em>) – If <code class="docutils literal notranslate"><span class="pre">True</span></code>, params could contain missing values, and the initializer will be |
| called to fill those missing params.</p></li> |
| <li><p><strong>force_init</strong> (<em>bool</em>) – If <code class="docutils literal notranslate"><span class="pre">True</span></code>, will force re-initialize even if already initialized.</p></li> |
| <li><p><strong>allow_extra</strong> (<em>boolean</em><em>, </em><em>optional</em>) – Whether allow extra parameters that are not needed by symbol. |
| If this is True, no error will be thrown when arg_params or aux_params |
| contain extra parameters that is not needed by the executor.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of setting module parameters.</span> |
| <span class="gp">>>> </span><span class="n">sym</span><span class="p">,</span> <span class="n">arg_params</span><span class="p">,</span> <span class="n">aux_params</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">model</span><span class="o">.</span><span class="n">load_checkpoint</span><span class="p">(</span><span class="n">model_prefix</span><span class="p">,</span> <span class="n">n_epoch_load</span><span class="p">)</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">set_params</span><span class="p">(</span><span class="n">arg_params</span><span class="o">=</span><span class="n">arg_params</span><span class="p">,</span> <span class="n">aux_params</span><span class="o">=</span><span class="n">aux_params</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.set_states"> |
| <code class="sig-name descname">set_states</code><span class="sig-paren">(</span><em class="sig-param">states=None</em>, <em class="sig-param">value=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.set_states"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.set_states" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Sets value for states. Only one of states & value can be specified.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>states</strong> (<em>list of list of NDArray</em>) – Source states arrays formatted like |
| <code class="docutils literal notranslate"><span class="pre">[[state1_dev1,</span> <span class="pre">state1_dev2],</span> <span class="pre">[state2_dev1,</span> <span class="pre">state2_dev2]]</span></code>.</p></li> |
| <li><p><strong>value</strong> (<em>number</em>) – A single scalar value for all state arrays.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.symbol"> |
| <em class="property">property </em><code class="sig-name descname">symbol</code><a class="headerlink" href="#mxnet.module.BaseModule.symbol" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets the symbol associated with this module.</p> |
| <p>Except for <cite>Module</cite>, for other types of modules (e.g. <cite>BucketingModule</cite>), this |
| property might not be a constant throughout its life time. Some modules might |
| not even be associated with any symbols.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.update"> |
| <code class="sig-name descname">update</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.update"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.update" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Updates parameters according to the installed optimizer and the gradients computed |
| in the previous forward-backward batch.</p> |
| <p>When KVStore is used to update parameters for multi-device or multi-machine training, |
| a copy of the parameters are stored in KVStore. Note that for <cite>row_sparse</cite> parameters, |
| this function does update the copy of parameters in KVStore, but doesn’t broadcast the |
| updated parameters to all devices / machines. Please call <cite>prepare</cite> to broadcast |
| <cite>row_sparse</cite> parameters with the next batch of data.</p> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of updating module parameters.</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">init_optimizer</span><span class="p">(</span><span class="n">kvstore</span><span class="o">=</span><span class="s1">'local'</span><span class="p">,</span> <span class="n">optimizer</span><span class="o">=</span><span class="s1">'sgd'</span><span class="p">,</span> |
| <span class="gp">... </span> <span class="n">optimizer_params</span><span class="o">=</span><span class="p">((</span><span class="s1">'learning_rate'</span><span class="p">,</span> <span class="mf">0.01</span><span class="p">),</span> <span class="p">))</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">backward</span><span class="p">()</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">update</span><span class="p">()</span> |
| <span class="gp">>>> </span><span class="nb">print</span> <span class="n">mod</span><span class="o">.</span><span class="n">get_params</span><span class="p">()[</span><span class="mi">0</span><span class="p">][</span><span class="s1">'fc3_weight'</span><span class="p">]</span><span class="o">.</span><span class="n">asnumpy</span><span class="p">()</span> |
| <span class="go">[[ 5.86930104e-03 5.28078526e-03 -8.88729654e-03 -1.08308345e-03</span> |
| <span class="go"> 6.13054074e-03 4.27560415e-03 1.53817423e-03 4.62131854e-03</span> |
| <span class="go"> 4.69872449e-03 -2.42400169e-03 9.94111411e-04 1.12386420e-03</span> |
| <span class="go"> ...]]</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BaseModule.update_metric"> |
| <code class="sig-name descname">update_metric</code><span class="sig-paren">(</span><em class="sig-param">eval_metric</em>, <em class="sig-param">labels</em>, <em class="sig-param">pre_sliced=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/base_module.html#BaseModule.update_metric"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BaseModule.update_metric" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Evaluates and accumulates evaluation metric on outputs of the last forward |
| computation.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>eval_metric</strong> (<a class="reference internal" href="../metric/index.html#mxnet.metric.EvalMetric" title="mxnet.metric.EvalMetric"><em>EvalMetric</em></a>) – Evaluation metric to use.</p></li> |
| <li><p><strong>labels</strong> (list of NDArray if <cite>pre_sliced</cite> parameter is set to <cite>False</cite>,) – list of lists of NDArray otherwise. Typically <cite>data_batch.label</cite>.</p></li> |
| <li><p><strong>pre_sliced</strong> (<em>bool</em>) – Whether the labels are already sliced per device (default: False).</p></li> |
| </ul> |
| </dd> |
| </dl> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of updating evaluation metric.</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">forward</span><span class="p">(</span><span class="n">data_batch</span><span class="p">)</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">update_metric</span><span class="p">(</span><span class="n">metric</span><span class="p">,</span> <span class="n">data_batch</span><span class="o">.</span><span class="n">label</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| </dd></dl> |
| |
| <dl class="class"> |
| <dt id="mxnet.module.BucketingModule"> |
| <em class="property">class </em><code class="sig-prename descclassname">mxnet.module.</code><code class="sig-name descname">BucketingModule</code><span class="sig-paren">(</span><em class="sig-param">sym_gen</em>, <em class="sig-param">default_bucket_key=None</em>, <em class="sig-param">logger=<module 'logging' from '/work/conda_env/lib/python3.9/logging/__init__.py'></em>, <em class="sig-param">context=cpu(0)</em>, <em class="sig-param">work_load_list=None</em>, <em class="sig-param">fixed_param_names=None</em>, <em class="sig-param">state_names=None</em>, <em class="sig-param">group2ctxs=None</em>, <em class="sig-param">compression_params=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">mxnet.module.base_module.BaseModule</span></code></p> |
| <p>This module helps to deal efficiently with varying-length inputs.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>sym_gen</strong> (<em>function</em>) – A function when called with a bucket key, returns a triple |
| <code class="docutils literal notranslate"><span class="pre">(symbol,</span> <span class="pre">data_names,</span> <span class="pre">label_names)</span></code>.</p></li> |
| <li><p><strong>default_bucket_key</strong> (<em>str</em><em> (or </em><em>any python object</em><em>)</em>) – The key for the default bucket.</p></li> |
| <li><p><strong>logger</strong> (<em>Logger</em>) – </p></li> |
| <li><p><strong>context</strong> (<a class="reference internal" href="../mxnet/context/index.html#mxnet.context.Context" title="mxnet.context.Context"><em>Context</em></a><em> or </em><em>list of Context</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">mx.cpu()</span></code></p></li> |
| <li><p><strong>work_load_list</strong> (<em>list of number</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">None</span></code>, indicating uniform workload.</p></li> |
| <li><p><strong>fixed_param_names</strong> (<em>list of str</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">None</span></code>, indicating no network parameters are fixed.</p></li> |
| <li><p><strong>state_names</strong> (<em>list of str</em>) – States are similar to data and label, but not provided by data iterator. |
| Instead they are initialized to 0 and can be set by set_states()</p></li> |
| <li><p><strong>group2ctxs</strong> (<em>dict of str to context</em><em> or </em><em>list of context</em><em>,</em>) – or list of dict of str to context |
| Default is <cite>None</cite>. Mapping the <cite>ctx_group</cite> attribute to the context assignment.</p></li> |
| <li><p><strong>compression_params</strong> (<em>dict</em>) – Specifies type of gradient compression and additional arguments depending |
| on the type of compression being used. For example, 2bit compression requires a threshold. |
| Arguments would then be {‘type’:’2bit’, ‘threshold’:0.5} |
| See mxnet.KVStore.set_gradient_compression method for more details on gradient compression.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| <p><strong>Methods</strong></p> |
| <table class="longtable docutils align-default"> |
| <colgroup> |
| <col style="width: 10%" /> |
| <col style="width: 90%" /> |
| </colgroup> |
| <tbody> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.backward" title="mxnet.module.BucketingModule.backward"><code class="xref py py-obj docutils literal notranslate"><span class="pre">backward</span></code></a>([out_grads])</p></td> |
| <td><p>Backward computation.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.bind" title="mxnet.module.BucketingModule.bind"><code class="xref py py-obj docutils literal notranslate"><span class="pre">bind</span></code></a>(data_shapes[, label_shapes, …])</p></td> |
| <td><p>Binding for a <cite>BucketingModule</cite> means setting up the buckets and binding the executor for the default bucket key.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.forward" title="mxnet.module.BucketingModule.forward"><code class="xref py py-obj docutils literal notranslate"><span class="pre">forward</span></code></a>(data_batch[, is_train])</p></td> |
| <td><p>Forward computation.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.get_input_grads" title="mxnet.module.BucketingModule.get_input_grads"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_input_grads</span></code></a>([merge_multi_context])</p></td> |
| <td><p>Gets the gradients with respect to the inputs of the module.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.get_outputs" title="mxnet.module.BucketingModule.get_outputs"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_outputs</span></code></a>([merge_multi_context])</p></td> |
| <td><p>Gets outputs from a previous forward computation.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.get_params" title="mxnet.module.BucketingModule.get_params"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_params</span></code></a>()</p></td> |
| <td><p>Gets current parameters.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.get_states" title="mxnet.module.BucketingModule.get_states"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_states</span></code></a>([merge_multi_context])</p></td> |
| <td><p>Gets states from all devices.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.init_optimizer" title="mxnet.module.BucketingModule.init_optimizer"><code class="xref py py-obj docutils literal notranslate"><span class="pre">init_optimizer</span></code></a>([kvstore, optimizer, …])</p></td> |
| <td><p>Installs and initializes optimizers.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.init_params" title="mxnet.module.BucketingModule.init_params"><code class="xref py py-obj docutils literal notranslate"><span class="pre">init_params</span></code></a>([initializer, arg_params, …])</p></td> |
| <td><p>Initializes parameters.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.install_monitor" title="mxnet.module.BucketingModule.install_monitor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">install_monitor</span></code></a>(mon)</p></td> |
| <td><p>Installs monitor on all executors</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.load" title="mxnet.module.BucketingModule.load"><code class="xref py py-obj docutils literal notranslate"><span class="pre">load</span></code></a>(prefix, epoch[, sym_gen, …])</p></td> |
| <td><p>Creates a model from previously saved checkpoint.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.load_dict" title="mxnet.module.BucketingModule.load_dict"><code class="xref py py-obj docutils literal notranslate"><span class="pre">load_dict</span></code></a>([sym_dict, sym_gen, …])</p></td> |
| <td><p>Creates a model from a dict mapping bucket_key to symbols and shared arg_params and aux_params.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.prepare" title="mxnet.module.BucketingModule.prepare"><code class="xref py py-obj docutils literal notranslate"><span class="pre">prepare</span></code></a>(data_batch[, sparse_row_id_fn])</p></td> |
| <td><p>Prepares the module for processing a data batch.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.save_checkpoint" title="mxnet.module.BucketingModule.save_checkpoint"><code class="xref py py-obj docutils literal notranslate"><span class="pre">save_checkpoint</span></code></a>(prefix, epoch[, remove_amp_cast])</p></td> |
| <td><p>Saves current progress to checkpoint for all buckets in BucketingModule Use <cite>mx.callback.module_checkpoint</cite> as <cite>epoch_end_callback</cite> to save during training.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.set_params" title="mxnet.module.BucketingModule.set_params"><code class="xref py py-obj docutils literal notranslate"><span class="pre">set_params</span></code></a>(arg_params, aux_params[, …])</p></td> |
| <td><p>Assigns parameters and aux state values.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.set_states" title="mxnet.module.BucketingModule.set_states"><code class="xref py py-obj docutils literal notranslate"><span class="pre">set_states</span></code></a>([states, value])</p></td> |
| <td><p>Sets value for states.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.switch_bucket" title="mxnet.module.BucketingModule.switch_bucket"><code class="xref py py-obj docutils literal notranslate"><span class="pre">switch_bucket</span></code></a>(bucket_key, data_shapes[, …])</p></td> |
| <td><p>Switches to a different bucket.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.update" title="mxnet.module.BucketingModule.update"><code class="xref py py-obj docutils literal notranslate"><span class="pre">update</span></code></a>()</p></td> |
| <td><p>Updates parameters according to installed optimizer and the gradient computed in the previous forward-backward cycle.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.update_metric" title="mxnet.module.BucketingModule.update_metric"><code class="xref py py-obj docutils literal notranslate"><span class="pre">update_metric</span></code></a>(eval_metric, labels[, pre_sliced])</p></td> |
| <td><p>Evaluates and accumulates evaluation metric on outputs of the last forward computation.</p></td> |
| </tr> |
| </tbody> |
| </table> |
| <p><strong>Attributes</strong></p> |
| <table class="longtable docutils align-default"> |
| <colgroup> |
| <col style="width: 10%" /> |
| <col style="width: 90%" /> |
| </colgroup> |
| <tbody> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.data_names" title="mxnet.module.BucketingModule.data_names"><code class="xref py py-obj docutils literal notranslate"><span class="pre">data_names</span></code></a></p></td> |
| <td><p>A list of names for data required by this module.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.data_shapes" title="mxnet.module.BucketingModule.data_shapes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">data_shapes</span></code></a></p></td> |
| <td><p>Get data shapes.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.label_shapes" title="mxnet.module.BucketingModule.label_shapes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">label_shapes</span></code></a></p></td> |
| <td><p>Get label shapes.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.output_names" title="mxnet.module.BucketingModule.output_names"><code class="xref py py-obj docutils literal notranslate"><span class="pre">output_names</span></code></a></p></td> |
| <td><p>A list of names for the outputs of this module.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.output_shapes" title="mxnet.module.BucketingModule.output_shapes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">output_shapes</span></code></a></p></td> |
| <td><p>Gets output shapes.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.BucketingModule.symbol" title="mxnet.module.BucketingModule.symbol"><code class="xref py py-obj docutils literal notranslate"><span class="pre">symbol</span></code></a></p></td> |
| <td><p>The symbol of the current bucket being used.</p></td> |
| </tr> |
| </tbody> |
| </table> |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.backward"> |
| <code class="sig-name descname">backward</code><span class="sig-paren">(</span><em class="sig-param">out_grads=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule.backward"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule.backward" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Backward computation.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.bind"> |
| <code class="sig-name descname">bind</code><span class="sig-paren">(</span><em class="sig-param">data_shapes</em>, <em class="sig-param">label_shapes=None</em>, <em class="sig-param">for_training=True</em>, <em class="sig-param">inputs_need_grad=False</em>, <em class="sig-param">force_rebind=False</em>, <em class="sig-param">shared_module=None</em>, <em class="sig-param">grad_req='write'</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule.bind"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule.bind" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Binding for a <cite>BucketingModule</cite> means setting up the buckets and binding the |
| executor for the default bucket key. Executors corresponding to other keys are |
| bound afterwards with <cite>switch_bucket</cite>.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>data_shapes</strong> (<em>list of</em><em> (</em><em>str</em><em>, </em><em>tuple</em><em>)</em>) – This should correspond to the symbol for the default bucket.</p></li> |
| <li><p><strong>label_shapes</strong> (<em>list of</em><em> (</em><em>str</em><em>, </em><em>tuple</em><em>)</em>) – This should correspond to the symbol for the default bucket.</p></li> |
| <li><p><strong>for_training</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">True</span></code>.</p></li> |
| <li><p><strong>inputs_need_grad</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p></li> |
| <li><p><strong>force_rebind</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p></li> |
| <li><p><strong>shared_module</strong> (<a class="reference internal" href="#mxnet.module.BucketingModule" title="mxnet.module.BucketingModule"><em>BucketingModule</em></a>) – Default is <code class="docutils literal notranslate"><span class="pre">None</span></code>. This value is currently not used.</p></li> |
| <li><p><strong>grad_req</strong> (<em>str</em><em>, </em><em>list of str</em><em>, </em><em>dict of str to str</em>) – Requirement for gradient accumulation. Can be ‘write’, ‘add’, or ‘null’ |
| (default to ‘write’). |
| Can be specified globally (str) or for each argument (list, dict).</p></li> |
| <li><p><strong>bucket_key</strong> (<em>str</em><em> (or </em><em>any python object</em><em>)</em>) – bucket key for binding. by default use the default_bucket_key</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.data_names"> |
| <em class="property">property </em><code class="sig-name descname">data_names</code><a class="headerlink" href="#mxnet.module.BucketingModule.data_names" title="Permalink to this definition">¶</a></dt> |
| <dd><p>A list of names for data required by this module.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.data_shapes"> |
| <em class="property">property </em><code class="sig-name descname">data_shapes</code><a class="headerlink" href="#mxnet.module.BucketingModule.data_shapes" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Get data shapes.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Returns</dt> |
| <dd class="field-odd"><p></p> |
| </dd> |
| <dt class="field-even">Return type</dt> |
| <dd class="field-even"><p>A list of <cite>(name, shape)</cite> pairs.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.forward"> |
| <code class="sig-name descname">forward</code><span class="sig-paren">(</span><em class="sig-param">data_batch</em>, <em class="sig-param">is_train=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule.forward"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule.forward" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Forward computation.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>data_batch</strong> (<a class="reference internal" href="../mxnet/io/index.html#mxnet.io.DataBatch" title="mxnet.io.DataBatch"><em>DataBatch</em></a>) – </p></li> |
| <li><p><strong>is_train</strong> (<em>bool</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">None</span></code>, in which case <cite>is_train</cite> is take as <code class="docutils literal notranslate"><span class="pre">self.for_training</span></code>.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.get_input_grads"> |
| <code class="sig-name descname">get_input_grads</code><span class="sig-paren">(</span><em class="sig-param">merge_multi_context=True</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule.get_input_grads"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule.get_input_grads" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets the gradients with respect to the inputs of the module.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>merge_multi_context</strong> (<em>bool</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">True</span></code>. In the case when data-parallelism is used, the outputs |
| will be collected from multiple devices. A <code class="docutils literal notranslate"><span class="pre">True</span></code> value indicate that we |
| should merge the collected results so that they look like from a single |
| executor.</p> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>If <cite>merge_multi_context</cite> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, it is like <code class="docutils literal notranslate"><span class="pre">[grad1,</span> <span class="pre">grad2]</span></code>. Otherwise, it |
| is like <code class="docutils literal notranslate"><span class="pre">[[grad1_dev1,</span> <span class="pre">grad1_dev2],</span> <span class="pre">[grad2_dev1,</span> <span class="pre">grad2_dev2]]</span></code>. All the output |
| elements are <cite>NDArray</cite>.</p> |
| </dd> |
| <dt class="field-odd">Return type</dt> |
| <dd class="field-odd"><p>list of NDArrays or list of list of NDArrays</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.get_outputs"> |
| <code class="sig-name descname">get_outputs</code><span class="sig-paren">(</span><em class="sig-param">merge_multi_context=True</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule.get_outputs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule.get_outputs" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets outputs from a previous forward computation.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>merge_multi_context</strong> (<em>bool</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">True</span></code>. In the case when data-parallelism is used, the outputs |
| will be collected from multiple devices. A <code class="docutils literal notranslate"><span class="pre">True</span></code> value indicate that we |
| should merge the collected results so that they look like from a single |
| executor.</p> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>If <cite>merge_multi_context</cite> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, it is like <code class="docutils literal notranslate"><span class="pre">[out1,</span> <span class="pre">out2]</span></code>. Otherwise, it |
| is like <code class="docutils literal notranslate"><span class="pre">[[out1_dev1,</span> <span class="pre">out1_dev2],</span> <span class="pre">[out2_dev1,</span> <span class="pre">out2_dev2]]</span></code>. All the output |
| elements are numpy arrays.</p> |
| </dd> |
| <dt class="field-odd">Return type</dt> |
| <dd class="field-odd"><p>list of numpy arrays or list of list of numpy arrays</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.get_params"> |
| <code class="sig-name descname">get_params</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule.get_params"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule.get_params" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets current parameters.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Returns</dt> |
| <dd class="field-odd"><p>A pair of dictionaries each mapping parameter names to NDArray values.</p> |
| </dd> |
| <dt class="field-even">Return type</dt> |
| <dd class="field-even"><p><cite>(arg_params, aux_params)</cite></p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.get_states"> |
| <code class="sig-name descname">get_states</code><span class="sig-paren">(</span><em class="sig-param">merge_multi_context=True</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule.get_states"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule.get_states" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets states from all devices.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>merge_multi_context</strong> (<em>bool</em>) – Default is <cite>True</cite>. In the case when data-parallelism is used, the states |
| will be collected from multiple devices. A <cite>True</cite> value indicate that we |
| should merge the collected results so that they look like from a single |
| executor.</p> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>If <cite>merge_multi_context</cite> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, it is like <code class="docutils literal notranslate"><span class="pre">[out1,</span> <span class="pre">out2]</span></code>. Otherwise, it |
| is like <code class="docutils literal notranslate"><span class="pre">[[out1_dev1,</span> <span class="pre">out1_dev2],</span> <span class="pre">[out2_dev1,</span> <span class="pre">out2_dev2]]</span></code>. All the output |
| elements are <cite>NDArray</cite>.</p> |
| </dd> |
| <dt class="field-odd">Return type</dt> |
| <dd class="field-odd"><p>list of NDArrays or list of list of NDArrays</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.init_optimizer"> |
| <code class="sig-name descname">init_optimizer</code><span class="sig-paren">(</span><em class="sig-param">kvstore='local'</em>, <em class="sig-param">optimizer='sgd'</em>, <em class="sig-param">optimizer_params=(('learning_rate'</em>, <em class="sig-param">0.01)</em>, <em class="sig-param">)</em>, <em class="sig-param">force_init=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule.init_optimizer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule.init_optimizer" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Installs and initializes optimizers.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>kvstore</strong> (<em>str</em><em> or </em><em>KVStore</em>) – Defaults to <cite>‘local’</cite>.</p></li> |
| <li><p><strong>optimizer</strong> (<em>str</em><em> or </em><a class="reference internal" href="../optimizer/index.html#mxnet.optimizer.Optimizer" title="mxnet.optimizer.Optimizer"><em>Optimizer</em></a>) – Defaults to <cite>‘sgd’</cite></p></li> |
| <li><p><strong>optimizer_params</strong> (<em>dict</em>) – Defaults to <cite>((‘learning_rate’, 0.01),)</cite>. The default value is not a dictionary, |
| just to avoid pylint warning of dangerous default values.</p></li> |
| <li><p><strong>force_init</strong> (<em>bool</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">False</span></code>, indicating whether we should force re-initializing the |
| optimizer in the case an optimizer is already installed.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.init_params"> |
| <code class="sig-name descname">init_params</code><span class="sig-paren">(</span><em class="sig-param">initializer=<mxnet.initializer.Uniform object></em>, <em class="sig-param">arg_params=None</em>, <em class="sig-param">aux_params=None</em>, <em class="sig-param">allow_missing=False</em>, <em class="sig-param">force_init=False</em>, <em class="sig-param">allow_extra=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule.init_params"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule.init_params" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Initializes parameters.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>initializer</strong> (<a class="reference internal" href="../initializer/index.html#mxnet.initializer.Initializer" title="mxnet.initializer.Initializer"><em>Initializer</em></a>) – </p></li> |
| <li><p><strong>arg_params</strong> (<em>dict</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">None</span></code>. Existing parameters. This has higher priority |
| than <cite>initializer</cite>.</p></li> |
| <li><p><strong>aux_params</strong> (<em>dict</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">None</span></code>. Existing auxiliary states. This has higher priority |
| than <cite>initializer</cite>.</p></li> |
| <li><p><strong>allow_missing</strong> (<em>bool</em>) – Allow missing values in <cite>arg_params</cite> and <cite>aux_params</cite> (if not <code class="docutils literal notranslate"><span class="pre">None</span></code>). |
| In this case, missing values will be filled with <cite>initializer</cite>.</p></li> |
| <li><p><strong>force_init</strong> (<em>bool</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p></li> |
| <li><p><strong>allow_extra</strong> (<em>boolean</em><em>, </em><em>optional</em>) – Whether allow extra parameters that are not needed by symbol. |
| If this is True, no error will be thrown when arg_params or aux_params |
| contain extra parameters that is not needed by the executor.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.install_monitor"> |
| <code class="sig-name descname">install_monitor</code><span class="sig-paren">(</span><em class="sig-param">mon</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule.install_monitor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule.install_monitor" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Installs monitor on all executors</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.label_shapes"> |
| <em class="property">property </em><code class="sig-name descname">label_shapes</code><a class="headerlink" href="#mxnet.module.BucketingModule.label_shapes" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Get label shapes.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Returns</dt> |
| <dd class="field-odd"><p>The return value could be <code class="docutils literal notranslate"><span class="pre">None</span></code> if the module does not need labels, |
| or if the module is not bound for training (in this case, label information |
| is not available).</p> |
| </dd> |
| <dt class="field-even">Return type</dt> |
| <dd class="field-even"><p>A list of <cite>(name, shape)</cite> pairs.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.load"> |
| <em class="property">static </em><code class="sig-name descname">load</code><span class="sig-paren">(</span><em class="sig-param">prefix</em>, <em class="sig-param">epoch</em>, <em class="sig-param">sym_gen=None</em>, <em class="sig-param">default_bucket_key=None</em>, <em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule.load"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule.load" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Creates a model from previously saved checkpoint.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>prefix</strong> (<em>str</em>) – path prefix of saved model files. You should have |
| “prefix-symbol.json”, “prefix-xxxx.params”, and |
| optionally “prefix-xxxx.states”, where xxxx is the |
| epoch number.</p></li> |
| <li><p><strong>epoch</strong> (<em>int</em>) – epoch to load.</p></li> |
| <li><p><strong>sym_gen</strong> (<em>function</em>) – A function when called with a bucket key, returns a triple |
| <code class="docutils literal notranslate"><span class="pre">(symbol,</span> <span class="pre">data_names,</span> <span class="pre">label_names)</span></code>. |
| provide sym_gen which was used when saving bucketing module.</p></li> |
| <li><p><strong>logger</strong> (<em>Logger</em>) – Default is <cite>logging</cite>.</p></li> |
| <li><p><strong>context</strong> (<a class="reference internal" href="../mxnet/context/index.html#mxnet.context.Context" title="mxnet.context.Context"><em>Context</em></a><em> or </em><em>list of Context</em>) – Default is <code class="docutils literal notranslate"><span class="pre">cpu()</span></code>.</p></li> |
| <li><p><strong>work_load_list</strong> (<em>list of number</em>) – Default <code class="docutils literal notranslate"><span class="pre">None</span></code>, indicating uniform workload.</p></li> |
| <li><p><strong>fixed_param_names</strong> (<em>list of str</em>) – Default <code class="docutils literal notranslate"><span class="pre">None</span></code>, indicating no network parameters are fixed.</p></li> |
| <li><p><strong>state_names</strong> (<em>list of str</em>) – States are similar to data and label, but not provided by data iterator. |
| Instead they are initialized to 0 and can be set by set_states()</p></li> |
| <li><p><strong>group2ctxs</strong> (<em>dict of str to context</em><em> or </em><em>list of context</em><em>,</em>) – or list of dict of str to context |
| Default is <cite>None</cite>. Mapping the <cite>ctx_group</cite> attribute to the context assignment.</p></li> |
| <li><p><strong>compression_params</strong> (<em>dict</em>) – Specifies type of gradient compression and additional arguments depending |
| on the type of compression being used. For example, 2bit compression requires a threshold. |
| Arguments would then be {‘type’:’2bit’, ‘threshold’:0.5} |
| See mxnet.KVStore.set_gradient_compression method for more details on gradient compression.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.load_dict"> |
| <em class="property">static </em><code class="sig-name descname">load_dict</code><span class="sig-paren">(</span><em class="sig-param">sym_dict=None</em>, <em class="sig-param">sym_gen=None</em>, <em class="sig-param">default_bucket_key=None</em>, <em class="sig-param">arg_params=None</em>, <em class="sig-param">aux_params=None</em>, <em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule.load_dict"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule.load_dict" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Creates a model from a dict mapping bucket_key to symbols and shared arg_params |
| and aux_params.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>sym_dict</strong> (<em>dict mapping bucket_key to symbol</em>) – Dict mapping bucket key to symbol</p></li> |
| <li><p><strong>sym_gen</strong> (<em>function</em>) – A function when called with a bucket key, returns a triple |
| <code class="docutils literal notranslate"><span class="pre">(symbol,</span> <span class="pre">data_names,</span> <span class="pre">label_names)</span></code>. |
| provide sym_gen which was used when saving bucketing module.</p></li> |
| <li><p><strong>default_bucket_key</strong> (<em>str</em><em> (or </em><em>any python object</em><em>)</em>) – The key for the default bucket.</p></li> |
| <li><p><strong>arg_params</strong> (<em>dict</em>) – Required for loading the BucketingModule. |
| Dict of name to parameter ndarrays.</p></li> |
| <li><p><strong>aux_params</strong> (<em>dict</em>) – Required for loading the BucketingModule. |
| Dict of name to auxiliary state ndarrays.</p></li> |
| <li><p><strong>logger</strong> (<em>Logger</em>) – Default is <cite>logging</cite>.</p></li> |
| <li><p><strong>context</strong> (<a class="reference internal" href="../mxnet/context/index.html#mxnet.context.Context" title="mxnet.context.Context"><em>Context</em></a><em> or </em><em>list of Context</em>) – Default is <code class="docutils literal notranslate"><span class="pre">cpu()</span></code>.</p></li> |
| <li><p><strong>work_load_list</strong> (<em>list of number</em>) – Default <code class="docutils literal notranslate"><span class="pre">None</span></code>, indicating uniform workload.</p></li> |
| <li><p><strong>fixed_param_names</strong> (<em>list of str</em>) – Default <code class="docutils literal notranslate"><span class="pre">None</span></code>, indicating no network parameters are fixed.</p></li> |
| <li><p><strong>state_names</strong> (<em>list of str</em>) – States are similar to data and label, but not provided by data iterator. |
| Instead they are initialized to 0 and can be set by set_states()</p></li> |
| <li><p><strong>group2ctxs</strong> (<em>dict of str to context</em><em> or </em><em>list of context</em><em>,</em>) – or list of dict of str to context |
| Default is <cite>None</cite>. Mapping the <cite>ctx_group</cite> attribute to the context assignment.</p></li> |
| <li><p><strong>compression_params</strong> (<em>dict</em>) – Specifies type of gradient compression and additional arguments depending |
| on the type of compression being used. For example, 2bit compression requires a threshold. |
| Arguments would then be {‘type’:’2bit’, ‘threshold’:0.5} |
| See mxnet.KVStore.set_gradient_compression method for more details on gradient compression.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.output_names"> |
| <em class="property">property </em><code class="sig-name descname">output_names</code><a class="headerlink" href="#mxnet.module.BucketingModule.output_names" title="Permalink to this definition">¶</a></dt> |
| <dd><p>A list of names for the outputs of this module.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.output_shapes"> |
| <em class="property">property </em><code class="sig-name descname">output_shapes</code><a class="headerlink" href="#mxnet.module.BucketingModule.output_shapes" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets output shapes.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Returns</dt> |
| <dd class="field-odd"><p></p> |
| </dd> |
| <dt class="field-even">Return type</dt> |
| <dd class="field-even"><p>A list of <cite>(name, shape)</cite> pairs.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.prepare"> |
| <code class="sig-name descname">prepare</code><span class="sig-paren">(</span><em class="sig-param">data_batch</em>, <em class="sig-param">sparse_row_id_fn=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule.prepare"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule.prepare" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Prepares the module for processing a data batch.</p> |
| <p>Usually involves switching bucket and reshaping. |
| For modules that contain <cite>row_sparse</cite> parameters in KVStore, |
| it prepares the <cite>row_sparse</cite> parameters based on the sparse_row_id_fn.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>data_batch</strong> (<a class="reference internal" href="../mxnet/io/index.html#mxnet.io.DataBatch" title="mxnet.io.DataBatch"><em>DataBatch</em></a>) – The current batch of data for forward computation.</p></li> |
| <li><p><strong>sparse_row_id_fn</strong> (<em>A callback function</em>) – The function takes <cite>data_batch</cite> as an input and returns a dict of |
| str -> NDArray. The resulting dict is used for pulling row_sparse |
| parameters from the kvstore, where the str key is the name of the param, |
| and the value is the row id of the param to pull.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.save_checkpoint"> |
| <code class="sig-name descname">save_checkpoint</code><span class="sig-paren">(</span><em class="sig-param">prefix</em>, <em class="sig-param">epoch</em>, <em class="sig-param">remove_amp_cast=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule.save_checkpoint"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule.save_checkpoint" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Saves current progress to checkpoint for all buckets in BucketingModule |
| Use <cite>mx.callback.module_checkpoint</cite> as <cite>epoch_end_callback</cite> to save during training.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>prefix</strong> (<em>str</em>) – The file prefix to checkpoint to.</p></li> |
| <li><p><strong>epoch</strong> (<em>int</em>) – The current epoch number.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.set_params"> |
| <code class="sig-name descname">set_params</code><span class="sig-paren">(</span><em class="sig-param">arg_params</em>, <em class="sig-param">aux_params</em>, <em class="sig-param">allow_missing=False</em>, <em class="sig-param">force_init=True</em>, <em class="sig-param">allow_extra=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule.set_params"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule.set_params" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Assigns parameters and aux state values.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>arg_params</strong> (<em>dict</em>) – Dictionary of name to value (<cite>NDArray</cite>) mapping.</p></li> |
| <li><p><strong>aux_params</strong> (<em>dict</em>) – Dictionary of name to value (<cite>NDArray</cite>) mapping.</p></li> |
| <li><p><strong>allow_missing</strong> (<em>bool</em>) – If true, params could contain missing values, and the initializer will be |
| called to fill those missing params.</p></li> |
| <li><p><strong>force_init</strong> (<em>bool</em>) – If true, will force re-initialize even if already initialized.</p></li> |
| <li><p><strong>allow_extra</strong> (<em>boolean</em><em>, </em><em>optional</em>) – Whether allow extra parameters that are not needed by symbol. |
| If this is True, no error will be thrown when arg_params or aux_params |
| contain extra parameters that is not needed by the executor.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of setting module parameters.</span> |
| <span class="gp">>>> </span><span class="n">sym</span><span class="p">,</span> <span class="n">arg_params</span><span class="p">,</span> <span class="n">aux_params</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">model</span><span class="o">.</span><span class="n">load_checkpoint</span><span class="p">(</span><span class="n">model_prefix</span><span class="p">,</span> <span class="n">n_epoch_load</span><span class="p">)</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">set_params</span><span class="p">(</span><span class="n">arg_params</span><span class="o">=</span><span class="n">arg_params</span><span class="p">,</span> <span class="n">aux_params</span><span class="o">=</span><span class="n">aux_params</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.set_states"> |
| <code class="sig-name descname">set_states</code><span class="sig-paren">(</span><em class="sig-param">states=None</em>, <em class="sig-param">value=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule.set_states"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule.set_states" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Sets value for states. Only one of states & values can be specified.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>states</strong> (<em>list of list of NDArrays</em>) – Source states arrays formatted like <code class="docutils literal notranslate"><span class="pre">[[state1_dev1,</span> <span class="pre">state1_dev2],</span> |
| <span class="pre">[state2_dev1,</span> <span class="pre">state2_dev2]]</span></code>.</p></li> |
| <li><p><strong>value</strong> (<em>number</em>) – A single scalar value for all state arrays.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.switch_bucket"> |
| <code class="sig-name descname">switch_bucket</code><span class="sig-paren">(</span><em class="sig-param">bucket_key</em>, <em class="sig-param">data_shapes</em>, <em class="sig-param">label_shapes=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule.switch_bucket"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule.switch_bucket" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Switches to a different bucket. This will change <code class="docutils literal notranslate"><span class="pre">self.curr_module</span></code>.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>bucket_key</strong> (<em>str</em><em> (or </em><em>any python object</em><em>)</em>) – The key of the target bucket.</p></li> |
| <li><p><strong>data_shapes</strong> (<em>list of</em><em> (</em><em>str</em><em>, </em><em>tuple</em><em>)</em>) – Typically <code class="docutils literal notranslate"><span class="pre">data_batch.provide_data</span></code>.</p></li> |
| <li><p><strong>label_shapes</strong> (<em>list of</em><em> (</em><em>str</em><em>, </em><em>tuple</em><em>)</em>) – Typically <code class="docutils literal notranslate"><span class="pre">data_batch.provide_label</span></code>.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.symbol"> |
| <em class="property">property </em><code class="sig-name descname">symbol</code><a class="headerlink" href="#mxnet.module.BucketingModule.symbol" title="Permalink to this definition">¶</a></dt> |
| <dd><p>The symbol of the current bucket being used.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.update"> |
| <code class="sig-name descname">update</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule.update"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule.update" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Updates parameters according to installed optimizer and the gradient computed |
| in the previous forward-backward cycle.</p> |
| <p>When KVStore is used to update parameters for multi-device or multi-machine training, |
| a copy of the parameters are stored in KVStore. Note that for <cite>row_sparse</cite> parameters, |
| this function does update the copy of parameters in KVStore, but doesn’t broadcast the |
| updated parameters to all devices / machines. Please call <cite>prepare</cite> to broadcast |
| <cite>row_sparse</cite> parameters with the next batch of data.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.BucketingModule.update_metric"> |
| <code class="sig-name descname">update_metric</code><span class="sig-paren">(</span><em class="sig-param">eval_metric</em>, <em class="sig-param">labels</em>, <em class="sig-param">pre_sliced=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/bucketing_module.html#BucketingModule.update_metric"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.BucketingModule.update_metric" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Evaluates and accumulates evaluation metric on outputs of the last forward computation.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>eval_metric</strong> (<a class="reference internal" href="../metric/index.html#mxnet.metric.EvalMetric" title="mxnet.metric.EvalMetric"><em>EvalMetric</em></a>) – </p></li> |
| <li><p><strong>labels</strong> (<em>list of NDArray</em>) – Typically <code class="docutils literal notranslate"><span class="pre">data_batch.label</span></code>.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| </dd></dl> |
| |
| <dl class="class"> |
| <dt id="mxnet.module.Module"> |
| <em class="property">class </em><code class="sig-prename descclassname">mxnet.module.</code><code class="sig-name descname">Module</code><span class="sig-paren">(</span><em class="sig-param">symbol</em>, <em class="sig-param">data_names=('data'</em>, <em class="sig-param">)</em>, <em class="sig-param">label_names=('softmax_label'</em>, <em class="sig-param">)</em>, <em class="sig-param">logger=<module 'logging' from '/work/conda_env/lib/python3.9/logging/__init__.py'></em>, <em class="sig-param">context=cpu(0)</em>, <em class="sig-param">work_load_list=None</em>, <em class="sig-param">fixed_param_names=None</em>, <em class="sig-param">state_names=None</em>, <em class="sig-param">group2ctxs=None</em>, <em class="sig-param">compression_params=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">mxnet.module.base_module.BaseModule</span></code></p> |
| <p>Module is a basic module that wrap a <cite>Symbol</cite>. It is functionally the same |
| as the <cite>FeedForward</cite> model, except under the module API.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>symbol</strong> (<a class="reference internal" href="../symbol/symbol.html#mxnet.symbol.Symbol" title="mxnet.symbol.Symbol"><em>Symbol</em></a>) – </p></li> |
| <li><p><strong>data_names</strong> (<em>list of str</em>) – Defaults to <cite>(‘data’)</cite> for a typical model used in image classification.</p></li> |
| <li><p><strong>label_names</strong> (<em>list of str</em>) – Defaults to <cite>(‘softmax_label’)</cite> for a typical model used in image |
| classification.</p></li> |
| <li><p><strong>logger</strong> (<em>Logger</em>) – Defaults to <cite>logging</cite>.</p></li> |
| <li><p><strong>context</strong> (<a class="reference internal" href="../mxnet/context/index.html#mxnet.context.Context" title="mxnet.context.Context"><em>Context</em></a><em> or </em><em>list of Context</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">mx.cpu()</span></code>.</p></li> |
| <li><p><strong>work_load_list</strong> (<em>list of number</em>) – Default <code class="docutils literal notranslate"><span class="pre">None</span></code>, indicating uniform workload.</p></li> |
| <li><p><strong>fixed_param_names</strong> (<em>list of str</em>) – Default <code class="docutils literal notranslate"><span class="pre">None</span></code>, indicating no network parameters are fixed.</p></li> |
| <li><p><strong>state_names</strong> (<em>list of str</em>) – states are similar to data and label, but not provided by data iterator. |
| Instead they are initialized to 0 and can be set by <cite>set_states()</cite>.</p></li> |
| <li><p><strong>group2ctxs</strong> (<em>dict of str to context</em><em> or </em><em>list of context</em><em>,</em>) – or list of dict of str to context |
| Default is <cite>None</cite>. Mapping the <cite>ctx_group</cite> attribute to the context assignment.</p></li> |
| <li><p><strong>compression_params</strong> (<em>dict</em>) – Specifies type of gradient compression and additional arguments depending |
| on the type of compression being used. For example, 2bit compression requires a threshold. |
| Arguments would then be {‘type’:’2bit’, ‘threshold’:0.5} |
| See mxnet.KVStore.set_gradient_compression method for more details on gradient compression.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| <p><strong>Methods</strong></p> |
| <table class="longtable docutils align-default"> |
| <colgroup> |
| <col style="width: 10%" /> |
| <col style="width: 90%" /> |
| </colgroup> |
| <tbody> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.Module.backward" title="mxnet.module.Module.backward"><code class="xref py py-obj docutils literal notranslate"><span class="pre">backward</span></code></a>([out_grads])</p></td> |
| <td><p>Backward computation.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.Module.bind" title="mxnet.module.Module.bind"><code class="xref py py-obj docutils literal notranslate"><span class="pre">bind</span></code></a>(data_shapes[, label_shapes, …])</p></td> |
| <td><p>Binds the symbols to construct executors.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.Module.borrow_optimizer" title="mxnet.module.Module.borrow_optimizer"><code class="xref py py-obj docutils literal notranslate"><span class="pre">borrow_optimizer</span></code></a>(shared_module)</p></td> |
| <td><p>Borrows optimizer from a shared module.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.Module.forward" title="mxnet.module.Module.forward"><code class="xref py py-obj docutils literal notranslate"><span class="pre">forward</span></code></a>(data_batch[, is_train])</p></td> |
| <td><p>Forward computation.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.Module.get_input_grads" title="mxnet.module.Module.get_input_grads"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_input_grads</span></code></a>([merge_multi_context])</p></td> |
| <td><p>Gets the gradients with respect to the inputs of the module.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.Module.get_outputs" title="mxnet.module.Module.get_outputs"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_outputs</span></code></a>([merge_multi_context])</p></td> |
| <td><p>Gets outputs of the previous forward computation.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.Module.get_params" title="mxnet.module.Module.get_params"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_params</span></code></a>()</p></td> |
| <td><p>Gets current parameters.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.Module.get_states" title="mxnet.module.Module.get_states"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_states</span></code></a>([merge_multi_context])</p></td> |
| <td><p>Gets states from all devices.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.Module.init_optimizer" title="mxnet.module.Module.init_optimizer"><code class="xref py py-obj docutils literal notranslate"><span class="pre">init_optimizer</span></code></a>([kvstore, optimizer, …])</p></td> |
| <td><p>Installs and initializes optimizers.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.Module.init_params" title="mxnet.module.Module.init_params"><code class="xref py py-obj docutils literal notranslate"><span class="pre">init_params</span></code></a>([initializer, arg_params, …])</p></td> |
| <td><p>Initializes the parameters and auxiliary states.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.Module.install_monitor" title="mxnet.module.Module.install_monitor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">install_monitor</span></code></a>(mon)</p></td> |
| <td><p>Installs monitor on all executors.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.Module.load" title="mxnet.module.Module.load"><code class="xref py py-obj docutils literal notranslate"><span class="pre">load</span></code></a>(prefix, epoch[, load_optimizer_states])</p></td> |
| <td><p>Creates a model from previously saved checkpoint.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.Module.load_optimizer_states" title="mxnet.module.Module.load_optimizer_states"><code class="xref py py-obj docutils literal notranslate"><span class="pre">load_optimizer_states</span></code></a>(fname)</p></td> |
| <td><p>Loads optimizer (updater) state from a file.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.Module.prepare" title="mxnet.module.Module.prepare"><code class="xref py py-obj docutils literal notranslate"><span class="pre">prepare</span></code></a>(data_batch[, sparse_row_id_fn])</p></td> |
| <td><p>Prepares the module for processing a data batch.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.Module.reshape" title="mxnet.module.Module.reshape"><code class="xref py py-obj docutils literal notranslate"><span class="pre">reshape</span></code></a>(data_shapes[, label_shapes])</p></td> |
| <td><p>Reshapes the module for new input shapes.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.Module.save_checkpoint" title="mxnet.module.Module.save_checkpoint"><code class="xref py py-obj docutils literal notranslate"><span class="pre">save_checkpoint</span></code></a>(prefix, epoch[, …])</p></td> |
| <td><p>Saves current progress to checkpoint.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.Module.save_optimizer_states" title="mxnet.module.Module.save_optimizer_states"><code class="xref py py-obj docutils literal notranslate"><span class="pre">save_optimizer_states</span></code></a>(fname)</p></td> |
| <td><p>Saves optimizer (updater) state to a file.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.Module.set_params" title="mxnet.module.Module.set_params"><code class="xref py py-obj docutils literal notranslate"><span class="pre">set_params</span></code></a>(arg_params, aux_params[, …])</p></td> |
| <td><p>Assigns parameter and aux state values.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.Module.set_states" title="mxnet.module.Module.set_states"><code class="xref py py-obj docutils literal notranslate"><span class="pre">set_states</span></code></a>([states, value])</p></td> |
| <td><p>Sets value for states.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.Module.update" title="mxnet.module.Module.update"><code class="xref py py-obj docutils literal notranslate"><span class="pre">update</span></code></a>()</p></td> |
| <td><p>Updates parameters according to the installed optimizer and the gradients computed in the previous forward-backward batch.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.Module.update_metric" title="mxnet.module.Module.update_metric"><code class="xref py py-obj docutils literal notranslate"><span class="pre">update_metric</span></code></a>(eval_metric, labels[, pre_sliced])</p></td> |
| <td><p>Evaluates and accumulates evaluation metric on outputs of the last forward computation.</p></td> |
| </tr> |
| </tbody> |
| </table> |
| <p><strong>Attributes</strong></p> |
| <table class="longtable docutils align-default"> |
| <colgroup> |
| <col style="width: 10%" /> |
| <col style="width: 90%" /> |
| </colgroup> |
| <tbody> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.Module.data_names" title="mxnet.module.Module.data_names"><code class="xref py py-obj docutils literal notranslate"><span class="pre">data_names</span></code></a></p></td> |
| <td><p>A list of names for data required by this module.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.Module.data_shapes" title="mxnet.module.Module.data_shapes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">data_shapes</span></code></a></p></td> |
| <td><p>Gets data shapes.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.Module.label_names" title="mxnet.module.Module.label_names"><code class="xref py py-obj docutils literal notranslate"><span class="pre">label_names</span></code></a></p></td> |
| <td><p>A list of names for labels required by this module.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.Module.label_shapes" title="mxnet.module.Module.label_shapes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">label_shapes</span></code></a></p></td> |
| <td><p>Gets label shapes.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.Module.output_names" title="mxnet.module.Module.output_names"><code class="xref py py-obj docutils literal notranslate"><span class="pre">output_names</span></code></a></p></td> |
| <td><p>A list of names for the outputs of this module.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.Module.output_shapes" title="mxnet.module.Module.output_shapes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">output_shapes</span></code></a></p></td> |
| <td><p>Gets output shapes.</p></td> |
| </tr> |
| </tbody> |
| </table> |
| <dl class="method"> |
| <dt id="mxnet.module.Module.backward"> |
| <code class="sig-name descname">backward</code><span class="sig-paren">(</span><em class="sig-param">out_grads=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.backward"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.backward" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Backward computation.</p> |
| <div class="admonition seealso"> |
| <p class="admonition-title">See also</p> |
| <p><a class="reference internal" href="#mxnet.module.BaseModule.backward" title="mxnet.module.BaseModule.backward"><code class="xref py py-meth docutils literal notranslate"><span class="pre">BaseModule.backward()</span></code></a></p> |
| </div> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>out_grads</strong> (<a class="reference internal" href="../ndarray/ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a><em> or </em><em>list of NDArray</em><em>, </em><em>optional</em>) – Gradient on the outputs to be propagated back. |
| This parameter is only needed when bind is called |
| on outputs that are not a loss function.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.bind"> |
| <code class="sig-name descname">bind</code><span class="sig-paren">(</span><em class="sig-param">data_shapes</em>, <em class="sig-param">label_shapes=None</em>, <em class="sig-param">for_training=True</em>, <em class="sig-param">inputs_need_grad=False</em>, <em class="sig-param">force_rebind=False</em>, <em class="sig-param">shared_module=None</em>, <em class="sig-param">grad_req='write'</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.bind"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.bind" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Binds the symbols to construct executors. This is necessary before one |
| can perform computation with the module.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>data_shapes</strong> (<em>list of</em><em> (</em><em>str</em><em>, </em><em>tuple</em><em>)</em>) – Typically is <code class="docutils literal notranslate"><span class="pre">data_iter.provide_data</span></code>.</p></li> |
| <li><p><strong>label_shapes</strong> (<em>list of</em><em> (</em><em>str</em><em>, </em><em>tuple</em><em>)</em>) – Typically is <code class="docutils literal notranslate"><span class="pre">data_iter.provide_label</span></code>.</p></li> |
| <li><p><strong>for_training</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">True</span></code>. Whether the executors should be bound for training.</p></li> |
| <li><p><strong>inputs_need_grad</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">False</span></code>. Whether the gradients to the input data need to be computed. |
| Typically this is not needed. But this might be needed when implementing composition |
| of modules.</p></li> |
| <li><p><strong>force_rebind</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">False</span></code>. This function does nothing if the executors are already |
| bound. But with this <code class="docutils literal notranslate"><span class="pre">True</span></code>, the executors will be forced to rebind.</p></li> |
| <li><p><strong>shared_module</strong> (<a class="reference internal" href="#mxnet.module.Module" title="mxnet.module.Module"><em>Module</em></a>) – Default is <code class="docutils literal notranslate"><span class="pre">None</span></code>. This is used in bucketing. When not <code class="docutils literal notranslate"><span class="pre">None</span></code>, the shared module |
| essentially corresponds to a different bucket – a module with different symbol |
| but with the same sets of parameters (e.g. unrolled RNNs with different lengths).</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.borrow_optimizer"> |
| <code class="sig-name descname">borrow_optimizer</code><span class="sig-paren">(</span><em class="sig-param">shared_module</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.borrow_optimizer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.borrow_optimizer" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Borrows optimizer from a shared module. Used in bucketing, where exactly the same |
| optimizer (esp. kvstore) is used.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>shared_module</strong> (<a class="reference internal" href="#mxnet.module.Module" title="mxnet.module.Module"><em>Module</em></a>) – </p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.data_names"> |
| <em class="property">property </em><code class="sig-name descname">data_names</code><a class="headerlink" href="#mxnet.module.Module.data_names" title="Permalink to this definition">¶</a></dt> |
| <dd><p>A list of names for data required by this module.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.data_shapes"> |
| <em class="property">property </em><code class="sig-name descname">data_shapes</code><a class="headerlink" href="#mxnet.module.Module.data_shapes" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets data shapes.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Returns</dt> |
| <dd class="field-odd"><p></p> |
| </dd> |
| <dt class="field-even">Return type</dt> |
| <dd class="field-even"><p>A list of <cite>(name, shape)</cite> pairs.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.forward"> |
| <code class="sig-name descname">forward</code><span class="sig-paren">(</span><em class="sig-param">data_batch</em>, <em class="sig-param">is_train=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.forward"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.forward" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Forward computation. It supports data batches with different shapes, such as |
| different batch sizes or different image sizes. |
| If reshaping of data batch relates to modification of symbol or module, such as |
| changing image layout ordering or switching from training to predicting, module |
| rebinding is required.</p> |
| <div class="admonition seealso"> |
| <p class="admonition-title">See also</p> |
| <p><a class="reference internal" href="#mxnet.module.BaseModule.forward" title="mxnet.module.BaseModule.forward"><code class="xref py py-meth docutils literal notranslate"><span class="pre">BaseModule.forward()</span></code></a></p> |
| </div> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>data_batch</strong> (<a class="reference internal" href="../mxnet/io/index.html#mxnet.io.DataBatch" title="mxnet.io.DataBatch"><em>DataBatch</em></a>) – Could be anything with similar API implemented.</p></li> |
| <li><p><strong>is_train</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">None</span></code>, which means <code class="docutils literal notranslate"><span class="pre">is_train</span></code> takes the value of <code class="docutils literal notranslate"><span class="pre">self.for_training</span></code>.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.get_input_grads"> |
| <code class="sig-name descname">get_input_grads</code><span class="sig-paren">(</span><em class="sig-param">merge_multi_context=True</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.get_input_grads"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.get_input_grads" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets the gradients with respect to the inputs of the module.</p> |
| <p>If <code class="docutils literal notranslate"><span class="pre">merge_multi_context</span></code> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, it is like <code class="docutils literal notranslate"><span class="pre">[grad1,</span> <span class="pre">grad2]</span></code>. Otherwise, it |
| is like <code class="docutils literal notranslate"><span class="pre">[[grad1_dev1,</span> <span class="pre">grad1_dev2],</span> <span class="pre">[grad2_dev1,</span> <span class="pre">grad2_dev2]]</span></code>. All the output |
| elements are <cite>NDArray</cite>.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>merge_multi_context</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">True</span></code>. In the case when data-parallelism is used, the outputs |
| will be collected from multiple devices. A <code class="docutils literal notranslate"><span class="pre">True</span></code> value indicate that we |
| should merge the collected results so that they look like from a single |
| executor.</p> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Input gradients</p> |
| </dd> |
| <dt class="field-odd">Return type</dt> |
| <dd class="field-odd"><p>list of NDArray or list of list of NDArray</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.get_outputs"> |
| <code class="sig-name descname">get_outputs</code><span class="sig-paren">(</span><em class="sig-param">merge_multi_context=True</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.get_outputs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.get_outputs" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets outputs of the previous forward computation.</p> |
| <p>If <code class="docutils literal notranslate"><span class="pre">merge_multi_context</span></code> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, it is like <code class="docutils literal notranslate"><span class="pre">[out1,</span> <span class="pre">out2]</span></code>. Otherwise, it |
| is like <code class="docutils literal notranslate"><span class="pre">[[out1_dev1,</span> <span class="pre">out1_dev2],</span> <span class="pre">[out2_dev1,</span> <span class="pre">out2_dev2]]</span></code>. All the output |
| elements are <cite>NDArray</cite>. When <cite>merge_multi_context</cite> is <cite>False</cite>, those <cite>NDArray</cite> |
| might live on different devices.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>merge_multi_context</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">True</span></code>. In the case when data-parallelism is used, the outputs |
| will be collected from multiple devices. A <code class="docutils literal notranslate"><span class="pre">True</span></code> value indicate that we |
| should merge the collected results so that they look like from a single |
| executor.</p> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>Output.</p> |
| </dd> |
| <dt class="field-odd">Return type</dt> |
| <dd class="field-odd"><p>list of NDArray or list of list of NDArray</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.get_params"> |
| <code class="sig-name descname">get_params</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.get_params"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.get_params" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets current parameters.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Returns</dt> |
| <dd class="field-odd"><p>A pair of dictionaries each mapping parameter names to NDArray values.</p> |
| </dd> |
| <dt class="field-even">Return type</dt> |
| <dd class="field-even"><p><cite>(arg_params, aux_params)</cite></p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.get_states"> |
| <code class="sig-name descname">get_states</code><span class="sig-paren">(</span><em class="sig-param">merge_multi_context=True</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.get_states"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.get_states" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets states from all devices.</p> |
| <p>If <cite>merge_multi_context</cite> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, it is like <code class="docutils literal notranslate"><span class="pre">[out1,</span> <span class="pre">out2]</span></code>. Otherwise, it |
| is like <code class="docutils literal notranslate"><span class="pre">[[out1_dev1,</span> <span class="pre">out1_dev2],</span> <span class="pre">[out2_dev1,</span> <span class="pre">out2_dev2]]</span></code>. All the output |
| elements are <cite>NDArray</cite>.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>merge_multi_context</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">True</span></code>. In the case when data-parallelism is used, the states |
| will be collected from multiple devices. A <code class="docutils literal notranslate"><span class="pre">True</span></code> value indicate that we |
| should merge the collected results so that they look like from a single |
| executor.</p> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>States</p> |
| </dd> |
| <dt class="field-odd">Return type</dt> |
| <dd class="field-odd"><p>list of NDArray or list of list of NDArray</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.init_optimizer"> |
| <code class="sig-name descname">init_optimizer</code><span class="sig-paren">(</span><em class="sig-param">kvstore='local'</em>, <em class="sig-param">optimizer='sgd'</em>, <em class="sig-param">optimizer_params=(('learning_rate'</em>, <em class="sig-param">0.01)</em>, <em class="sig-param">)</em>, <em class="sig-param">force_init=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.init_optimizer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.init_optimizer" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Installs and initializes optimizers.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>kvstore</strong> (<em>str</em><em> or </em><em>KVStore</em>) – Default <cite>‘local’</cite>.</p></li> |
| <li><p><strong>optimizer</strong> (<em>str</em><em> or </em><a class="reference internal" href="../optimizer/index.html#mxnet.optimizer.Optimizer" title="mxnet.optimizer.Optimizer"><em>Optimizer</em></a>) – Default <cite>‘sgd’</cite></p></li> |
| <li><p><strong>optimizer_params</strong> (<em>dict</em>) – Default <cite>((‘learning_rate’, 0.01),)</cite>. The default value is not a dictionary, |
| just to avoid pylint warning of dangerous default values.</p></li> |
| <li><p><strong>force_init</strong> (<em>bool</em>) – Default <code class="docutils literal notranslate"><span class="pre">False</span></code>, indicating whether we should force re-initializing the |
| optimizer in the case an optimizer is already installed.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.init_params"> |
| <code class="sig-name descname">init_params</code><span class="sig-paren">(</span><em class="sig-param">initializer=<mxnet.initializer.Uniform object></em>, <em class="sig-param">arg_params=None</em>, <em class="sig-param">aux_params=None</em>, <em class="sig-param">allow_missing=False</em>, <em class="sig-param">force_init=False</em>, <em class="sig-param">allow_extra=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.init_params"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.init_params" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Initializes the parameters and auxiliary states.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>initializer</strong> (<a class="reference internal" href="../initializer/index.html#mxnet.initializer.Initializer" title="mxnet.initializer.Initializer"><em>Initializer</em></a>) – Called to initialize parameters if needed.</p></li> |
| <li><p><strong>arg_params</strong> (<em>dict</em>) – If not <code class="docutils literal notranslate"><span class="pre">None</span></code>, should be a dictionary of existing arg_params. Initialization |
| will be copied from that.</p></li> |
| <li><p><strong>aux_params</strong> (<em>dict</em>) – If not <code class="docutils literal notranslate"><span class="pre">None</span></code>, should be a dictionary of existing aux_params. Initialization |
| will be copied from that.</p></li> |
| <li><p><strong>allow_missing</strong> (<em>bool</em>) – If <code class="docutils literal notranslate"><span class="pre">True</span></code>, params could contain missing values, and the initializer will be |
| called to fill those missing params.</p></li> |
| <li><p><strong>force_init</strong> (<em>bool</em>) – If <code class="docutils literal notranslate"><span class="pre">True</span></code>, will force re-initialize even if already initialized.</p></li> |
| <li><p><strong>allow_extra</strong> (<em>boolean</em><em>, </em><em>optional</em>) – Whether allow extra parameters that are not needed by symbol. |
| If this is True, no error will be thrown when arg_params or aux_params |
| contain extra parameters that is not needed by the executor.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.install_monitor"> |
| <code class="sig-name descname">install_monitor</code><span class="sig-paren">(</span><em class="sig-param">mon</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.install_monitor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.install_monitor" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Installs monitor on all executors.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.label_names"> |
| <em class="property">property </em><code class="sig-name descname">label_names</code><a class="headerlink" href="#mxnet.module.Module.label_names" title="Permalink to this definition">¶</a></dt> |
| <dd><p>A list of names for labels required by this module.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.label_shapes"> |
| <em class="property">property </em><code class="sig-name descname">label_shapes</code><a class="headerlink" href="#mxnet.module.Module.label_shapes" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets label shapes.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Returns</dt> |
| <dd class="field-odd"><p>The return value could be <code class="docutils literal notranslate"><span class="pre">None</span></code> if |
| the module does not need labels, or if the module is not bound for |
| training (in this case, label information is not available).</p> |
| </dd> |
| <dt class="field-even">Return type</dt> |
| <dd class="field-even"><p>A list of <cite>(name, shape)</cite> pairs.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.load"> |
| <em class="property">static </em><code class="sig-name descname">load</code><span class="sig-paren">(</span><em class="sig-param">prefix</em>, <em class="sig-param">epoch</em>, <em class="sig-param">load_optimizer_states=False</em>, <em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.load"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.load" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Creates a model from previously saved checkpoint.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>prefix</strong> (<em>str</em>) – path prefix of saved model files. You should have |
| “prefix-symbol.json”, “prefix-xxxx.params”, and |
| optionally “prefix-xxxx.states”, where xxxx is the |
| epoch number.</p></li> |
| <li><p><strong>epoch</strong> (<em>int</em>) – epoch to load.</p></li> |
| <li><p><strong>load_optimizer_states</strong> (<em>bool</em>) – whether to load optimizer states. Checkpoint needs |
| to have been made with save_optimizer_states=True.</p></li> |
| <li><p><strong>data_names</strong> (<em>list of str</em>) – Default is <cite>(‘data’)</cite> for a typical model used in image classification.</p></li> |
| <li><p><strong>label_names</strong> (<em>list of str</em>) – Default is <cite>(‘softmax_label’)</cite> for a typical model used in image |
| classification.</p></li> |
| <li><p><strong>logger</strong> (<em>Logger</em>) – Default is <cite>logging</cite>.</p></li> |
| <li><p><strong>context</strong> (<a class="reference internal" href="../mxnet/context/index.html#mxnet.context.Context" title="mxnet.context.Context"><em>Context</em></a><em> or </em><em>list of Context</em>) – Default is <code class="docutils literal notranslate"><span class="pre">cpu()</span></code>.</p></li> |
| <li><p><strong>work_load_list</strong> (<em>list of number</em>) – Default <code class="docutils literal notranslate"><span class="pre">None</span></code>, indicating uniform workload.</p></li> |
| <li><p><strong>fixed_param_names</strong> (<em>list of str</em>) – Default <code class="docutils literal notranslate"><span class="pre">None</span></code>, indicating no network parameters are fixed.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.load_optimizer_states"> |
| <code class="sig-name descname">load_optimizer_states</code><span class="sig-paren">(</span><em class="sig-param">fname</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.load_optimizer_states"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.load_optimizer_states" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Loads optimizer (updater) state from a file.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>fname</strong> (<em>str</em>) – Path to input states file.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.output_names"> |
| <em class="property">property </em><code class="sig-name descname">output_names</code><a class="headerlink" href="#mxnet.module.Module.output_names" title="Permalink to this definition">¶</a></dt> |
| <dd><p>A list of names for the outputs of this module.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.output_shapes"> |
| <em class="property">property </em><code class="sig-name descname">output_shapes</code><a class="headerlink" href="#mxnet.module.Module.output_shapes" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets output shapes.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Returns</dt> |
| <dd class="field-odd"><p></p> |
| </dd> |
| <dt class="field-even">Return type</dt> |
| <dd class="field-even"><p>A list of <cite>(name, shape)</cite> pairs.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.prepare"> |
| <code class="sig-name descname">prepare</code><span class="sig-paren">(</span><em class="sig-param">data_batch</em>, <em class="sig-param">sparse_row_id_fn=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.prepare"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.prepare" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Prepares the module for processing a data batch.</p> |
| <p>Usually involves switching bucket and reshaping. |
| For modules that contain <cite>row_sparse</cite> parameters in KVStore, |
| it prepares the <cite>row_sparse</cite> parameters based on the sparse_row_id_fn.</p> |
| <p>When KVStore is used to update parameters for multi-device or multi-machine training, |
| a copy of the parameters are stored in KVStore. Note that for <cite>row_sparse</cite> parameters, |
| the <cite>update()</cite> updates the copy of parameters in KVStore, but doesn’t broadcast |
| the updated parameters to all devices / machines. The <cite>prepare</cite> function is used to |
| broadcast <cite>row_sparse</cite> parameters with the next batch of data.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>data_batch</strong> (<a class="reference internal" href="../mxnet/io/index.html#mxnet.io.DataBatch" title="mxnet.io.DataBatch"><em>DataBatch</em></a>) – The current batch of data for forward computation.</p></li> |
| <li><p><strong>sparse_row_id_fn</strong> (<em>A callback function</em>) – The function takes <cite>data_batch</cite> as an input and returns a dict of |
| str -> NDArray. The resulting dict is used for pulling row_sparse |
| parameters from the kvstore, where the str key is the name of the param, |
| and the value is the row id of the param to pull.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.reshape"> |
| <code class="sig-name descname">reshape</code><span class="sig-paren">(</span><em class="sig-param">data_shapes</em>, <em class="sig-param">label_shapes=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.reshape"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.reshape" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Reshapes the module for new input shapes.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>data_shapes</strong> (<em>list of</em><em> (</em><em>str</em><em>, </em><em>tuple</em><em>)</em>) – Typically is <code class="docutils literal notranslate"><span class="pre">data_iter.provide_data</span></code>.</p></li> |
| <li><p><strong>label_shapes</strong> (<em>list of</em><em> (</em><em>str</em><em>, </em><em>tuple</em><em>)</em>) – Typically is <code class="docutils literal notranslate"><span class="pre">data_iter.provide_label</span></code>.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.save_checkpoint"> |
| <code class="sig-name descname">save_checkpoint</code><span class="sig-paren">(</span><em class="sig-param">prefix</em>, <em class="sig-param">epoch</em>, <em class="sig-param">save_optimizer_states=False</em>, <em class="sig-param">remove_amp_cast=True</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.save_checkpoint"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.save_checkpoint" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Saves current progress to checkpoint. |
| Use <cite>mx.callback.module_checkpoint</cite> as <cite>epoch_end_callback</cite> to save during training.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>prefix</strong> (<em>str</em>) – The file prefix to checkpoint to.</p></li> |
| <li><p><strong>epoch</strong> (<em>int</em>) – The current epoch number.</p></li> |
| <li><p><strong>save_optimizer_states</strong> (<em>bool</em>) – Whether to save optimizer states to continue training.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.save_optimizer_states"> |
| <code class="sig-name descname">save_optimizer_states</code><span class="sig-paren">(</span><em class="sig-param">fname</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.save_optimizer_states"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.save_optimizer_states" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Saves optimizer (updater) state to a file.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>fname</strong> (<em>str</em>) – Path to output states file.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.set_params"> |
| <code class="sig-name descname">set_params</code><span class="sig-paren">(</span><em class="sig-param">arg_params</em>, <em class="sig-param">aux_params</em>, <em class="sig-param">allow_missing=False</em>, <em class="sig-param">force_init=True</em>, <em class="sig-param">allow_extra=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.set_params"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.set_params" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Assigns parameter and aux state values.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>arg_params</strong> (<em>dict</em>) – Dictionary of name to <cite>NDArray</cite>.</p></li> |
| <li><p><strong>aux_params</strong> (<em>dict</em>) – Dictionary of name to <cite>NDArray</cite>.</p></li> |
| <li><p><strong>allow_missing</strong> (<em>bool</em>) – If <code class="docutils literal notranslate"><span class="pre">True</span></code>, params could contain missing values, and the initializer will be |
| called to fill those missing params.</p></li> |
| <li><p><strong>force_init</strong> (<em>bool</em>) – If <code class="docutils literal notranslate"><span class="pre">True</span></code>, will force re-initialize even if already initialized.</p></li> |
| <li><p><strong>allow_extra</strong> (<em>boolean</em><em>, </em><em>optional</em>) – Whether allow extra parameters that are not needed by symbol. |
| If this is True, no error will be thrown when arg_params or aux_params |
| contain extra parameters that is not needed by the executor.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of setting module parameters.</span> |
| <span class="gp">>>> </span><span class="n">sym</span><span class="p">,</span> <span class="n">arg_params</span><span class="p">,</span> <span class="n">aux_params</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">model</span><span class="o">.</span><span class="n">load_checkpoint</span><span class="p">(</span><span class="n">model_prefix</span><span class="p">,</span> <span class="n">n_epoch_load</span><span class="p">)</span> |
| <span class="gp">>>> </span><span class="n">mod</span><span class="o">.</span><span class="n">set_params</span><span class="p">(</span><span class="n">arg_params</span><span class="o">=</span><span class="n">arg_params</span><span class="p">,</span> <span class="n">aux_params</span><span class="o">=</span><span class="n">aux_params</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.set_states"> |
| <code class="sig-name descname">set_states</code><span class="sig-paren">(</span><em class="sig-param">states=None</em>, <em class="sig-param">value=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.set_states"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.set_states" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Sets value for states. Only one of the states & value can be specified.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>states</strong> (<em>list of list of NDArrays</em>) – source states arrays formatted like <code class="docutils literal notranslate"><span class="pre">[[state1_dev1,</span> <span class="pre">state1_dev2],</span> |
| <span class="pre">[state2_dev1,</span> <span class="pre">state2_dev2]]</span></code>.</p></li> |
| <li><p><strong>value</strong> (<em>number</em>) – a single scalar value for all state arrays.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.update"> |
| <code class="sig-name descname">update</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.update"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.update" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Updates parameters according to the installed optimizer and the gradients computed |
| in the previous forward-backward batch.</p> |
| <p>When KVStore is used to update parameters for multi-device or multi-machine training, |
| a copy of the parameters are stored in KVStore. Note that for <cite>row_sparse</cite> parameters, |
| this function does update the copy of parameters in KVStore, but doesn’t broadcast the |
| updated parameters to all devices / machines. Please call <cite>prepare</cite> to broadcast |
| <cite>row_sparse</cite> parameters with the next batch of data.</p> |
| <div class="admonition seealso"> |
| <p class="admonition-title">See also</p> |
| <p><a class="reference internal" href="#mxnet.module.BaseModule.update" title="mxnet.module.BaseModule.update"><code class="xref py py-meth docutils literal notranslate"><span class="pre">BaseModule.update()</span></code></a></p> |
| </div> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.Module.update_metric"> |
| <code class="sig-name descname">update_metric</code><span class="sig-paren">(</span><em class="sig-param">eval_metric</em>, <em class="sig-param">labels</em>, <em class="sig-param">pre_sliced=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/module.html#Module.update_metric"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.Module.update_metric" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Evaluates and accumulates evaluation metric on outputs of the last forward computation.</p> |
| <div class="admonition seealso"> |
| <p class="admonition-title">See also</p> |
| <p><a class="reference internal" href="#mxnet.module.BaseModule.update_metric" title="mxnet.module.BaseModule.update_metric"><code class="xref py py-meth docutils literal notranslate"><span class="pre">BaseModule.update_metric()</span></code></a></p> |
| </div> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>eval_metric</strong> (<a class="reference internal" href="../metric/index.html#mxnet.metric.EvalMetric" title="mxnet.metric.EvalMetric"><em>EvalMetric</em></a>) – Evaluation metric to use.</p></li> |
| <li><p><strong>labels</strong> (list of NDArray if <cite>pre_sliced</cite> parameter is set to <cite>False</cite>,) – list of lists of NDArray otherwise. Typically <cite>data_batch.label</cite>.</p></li> |
| <li><p><strong>pre_sliced</strong> (<em>bool</em>) – Whether the labels are already sliced per device (default: False).</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| </dd></dl> |
| |
| <dl class="class"> |
| <dt id="mxnet.module.PythonLossModule"> |
| <em class="property">class </em><code class="sig-prename descclassname">mxnet.module.</code><code class="sig-name descname">PythonLossModule</code><span class="sig-paren">(</span><em class="sig-param">name='pyloss'</em>, <em class="sig-param">data_names=('data'</em>, <em class="sig-param">)</em>, <em class="sig-param">label_names=('softmax_label'</em>, <em class="sig-param">)</em>, <em class="sig-param">logger=<module 'logging' from '/work/conda_env/lib/python3.9/logging/__init__.py'></em>, <em class="sig-param">grad_func=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/python_module.html#PythonLossModule"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.PythonLossModule" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">mxnet.module.python_module.PythonModule</span></code></p> |
| <p>A convenient module class that implements many of the module APIs as |
| empty functions.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>name</strong> (<em>str</em>) – Names of the module. The outputs will be named <cite>[name + ‘_output’]</cite>.</p></li> |
| <li><p><strong>data_names</strong> (<em>list of str</em>) – Defaults to <code class="docutils literal notranslate"><span class="pre">['data']</span></code>. Names of the data expected by this module. |
| Should be a list of only one name.</p></li> |
| <li><p><strong>label_names</strong> (<em>list of str</em>) – Default <code class="docutils literal notranslate"><span class="pre">['softmax_label']</span></code>. Names of the labels expected by the module. |
| Should be a list of only one name.</p></li> |
| <li><p><strong>grad_func</strong> (<em>function</em>) – Optional. If not <code class="docutils literal notranslate"><span class="pre">None</span></code>, should be a function that takes <cite>scores</cite> |
| and <cite>labels</cite>, both of type <cite>NDArray</cite>, and return the gradients with |
| respect to the scores according to this loss function. The return |
| value could be a numpy array or an <cite>NDArray</cite>.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| <p><strong>Methods</strong></p> |
| <table class="longtable docutils align-default"> |
| <colgroup> |
| <col style="width: 10%" /> |
| <col style="width: 90%" /> |
| </colgroup> |
| <tbody> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.PythonLossModule.backward" title="mxnet.module.PythonLossModule.backward"><code class="xref py py-obj docutils literal notranslate"><span class="pre">backward</span></code></a>([out_grads])</p></td> |
| <td><p>Backward computation.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.PythonLossModule.forward" title="mxnet.module.PythonLossModule.forward"><code class="xref py py-obj docutils literal notranslate"><span class="pre">forward</span></code></a>(data_batch[, is_train])</p></td> |
| <td><p>Forward computation.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.PythonLossModule.get_input_grads" title="mxnet.module.PythonLossModule.get_input_grads"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_input_grads</span></code></a>([merge_multi_context])</p></td> |
| <td><p>Gets the gradients to the inputs, computed in the previous backward computation.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.PythonLossModule.get_outputs" title="mxnet.module.PythonLossModule.get_outputs"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_outputs</span></code></a>([merge_multi_context])</p></td> |
| <td><p>Gets outputs of the previous forward computation.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.PythonLossModule.install_monitor" title="mxnet.module.PythonLossModule.install_monitor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">install_monitor</span></code></a>(mon)</p></td> |
| <td><p>Installs monitor on all executors.</p></td> |
| </tr> |
| </tbody> |
| </table> |
| <dl class="method"> |
| <dt id="mxnet.module.PythonLossModule.backward"> |
| <code class="sig-name descname">backward</code><span class="sig-paren">(</span><em class="sig-param">out_grads=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/python_module.html#PythonLossModule.backward"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.PythonLossModule.backward" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Backward computation.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>out_grads</strong> (<a class="reference internal" href="../ndarray/ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a><em> or </em><em>list of NDArray</em><em>, </em><em>optional</em>) – Gradient on the outputs to be propagated back. |
| This parameter is only needed when bind is called |
| on outputs that are not a loss function.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.PythonLossModule.forward"> |
| <code class="sig-name descname">forward</code><span class="sig-paren">(</span><em class="sig-param">data_batch</em>, <em class="sig-param">is_train=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/python_module.html#PythonLossModule.forward"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.PythonLossModule.forward" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Forward computation. Here we do nothing but to keep a reference to |
| the scores and the labels so that we can do backward computation.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>data_batch</strong> (<a class="reference internal" href="../mxnet/io/index.html#mxnet.io.DataBatch" title="mxnet.io.DataBatch"><em>DataBatch</em></a>) – Could be anything with similar API implemented.</p></li> |
| <li><p><strong>is_train</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">None</span></code>, which means <cite>is_train</cite> takes the value of <code class="docutils literal notranslate"><span class="pre">self.for_training</span></code>.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.PythonLossModule.get_input_grads"> |
| <code class="sig-name descname">get_input_grads</code><span class="sig-paren">(</span><em class="sig-param">merge_multi_context=True</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/python_module.html#PythonLossModule.get_input_grads"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.PythonLossModule.get_input_grads" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets the gradients to the inputs, computed in the previous backward computation.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>merge_multi_context</strong> (<em>bool</em>) – Should always be <code class="docutils literal notranslate"><span class="pre">True</span></code> because we do not use multiple context for computation.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.PythonLossModule.get_outputs"> |
| <code class="sig-name descname">get_outputs</code><span class="sig-paren">(</span><em class="sig-param">merge_multi_context=True</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/python_module.html#PythonLossModule.get_outputs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.PythonLossModule.get_outputs" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets outputs of the previous forward computation. As a output loss module, |
| we treat the inputs to this module as scores, and simply return them.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>merge_multi_context</strong> (<em>bool</em>) – Should always be <code class="docutils literal notranslate"><span class="pre">True</span></code>, because we do not use multiple contexts for computing.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.PythonLossModule.install_monitor"> |
| <code class="sig-name descname">install_monitor</code><span class="sig-paren">(</span><em class="sig-param">mon</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/python_module.html#PythonLossModule.install_monitor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.PythonLossModule.install_monitor" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Installs monitor on all executors.</p> |
| </dd></dl> |
| |
| </dd></dl> |
| |
| <dl class="class"> |
| <dt id="mxnet.module.PythonModule"> |
| <em class="property">class </em><code class="sig-prename descclassname">mxnet.module.</code><code class="sig-name descname">PythonModule</code><span class="sig-paren">(</span><em class="sig-param">data_names</em>, <em class="sig-param">label_names</em>, <em class="sig-param">output_names</em>, <em class="sig-param">logger=<module 'logging' from '/work/conda_env/lib/python3.9/logging/__init__.py'></em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/python_module.html#PythonModule"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.PythonModule" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">mxnet.module.base_module.BaseModule</span></code></p> |
| <p>A convenient module class that implements many of the module APIs as |
| empty functions.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>data_names</strong> (<em>list of str</em>) – Names of the data expected by the module.</p></li> |
| <li><p><strong>label_names</strong> (<em>list of str</em>) – Names of the labels expected by the module. Could be <code class="docutils literal notranslate"><span class="pre">None</span></code> if the |
| module does not need labels.</p></li> |
| <li><p><strong>output_names</strong> (<em>list of str</em>) – Names of the outputs.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| <p><strong>Methods</strong></p> |
| <table class="longtable docutils align-default"> |
| <colgroup> |
| <col style="width: 10%" /> |
| <col style="width: 90%" /> |
| </colgroup> |
| <tbody> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.PythonModule.bind" title="mxnet.module.PythonModule.bind"><code class="xref py py-obj docutils literal notranslate"><span class="pre">bind</span></code></a>(data_shapes[, label_shapes, …])</p></td> |
| <td><p>Binds the symbols to construct executors.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.PythonModule.get_params" title="mxnet.module.PythonModule.get_params"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_params</span></code></a>()</p></td> |
| <td><p>Gets parameters, those are potentially copies of the actual parameters used to do computation on the device.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.PythonModule.init_optimizer" title="mxnet.module.PythonModule.init_optimizer"><code class="xref py py-obj docutils literal notranslate"><span class="pre">init_optimizer</span></code></a>([kvstore, optimizer, …])</p></td> |
| <td><p>Installs and initializes optimizers.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.PythonModule.init_params" title="mxnet.module.PythonModule.init_params"><code class="xref py py-obj docutils literal notranslate"><span class="pre">init_params</span></code></a>([initializer, arg_params, …])</p></td> |
| <td><p>Initializes the parameters and auxiliary states.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.PythonModule.update" title="mxnet.module.PythonModule.update"><code class="xref py py-obj docutils literal notranslate"><span class="pre">update</span></code></a>()</p></td> |
| <td><p>Updates parameters according to the installed optimizer and the gradients computed in the previous forward-backward batch.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.PythonModule.update_metric" title="mxnet.module.PythonModule.update_metric"><code class="xref py py-obj docutils literal notranslate"><span class="pre">update_metric</span></code></a>(eval_metric, labels[, pre_sliced])</p></td> |
| <td><p>Evaluates and accumulates evaluation metric on outputs of the last forward computation.</p></td> |
| </tr> |
| </tbody> |
| </table> |
| <p><strong>Attributes</strong></p> |
| <table class="longtable docutils align-default"> |
| <colgroup> |
| <col style="width: 10%" /> |
| <col style="width: 90%" /> |
| </colgroup> |
| <tbody> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.PythonModule.data_names" title="mxnet.module.PythonModule.data_names"><code class="xref py py-obj docutils literal notranslate"><span class="pre">data_names</span></code></a></p></td> |
| <td><p>A list of names for data required by this module.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.PythonModule.data_shapes" title="mxnet.module.PythonModule.data_shapes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">data_shapes</span></code></a></p></td> |
| <td><p>A list of (name, shape) pairs specifying the data inputs to this module.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.PythonModule.label_shapes" title="mxnet.module.PythonModule.label_shapes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">label_shapes</span></code></a></p></td> |
| <td><p>A list of (name, shape) pairs specifying the label inputs to this module.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.PythonModule.output_names" title="mxnet.module.PythonModule.output_names"><code class="xref py py-obj docutils literal notranslate"><span class="pre">output_names</span></code></a></p></td> |
| <td><p>A list of names for the outputs of this module.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.PythonModule.output_shapes" title="mxnet.module.PythonModule.output_shapes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">output_shapes</span></code></a></p></td> |
| <td><p>A list of (name, shape) pairs specifying the outputs of this module.</p></td> |
| </tr> |
| </tbody> |
| </table> |
| <dl class="method"> |
| <dt id="mxnet.module.PythonModule.bind"> |
| <code class="sig-name descname">bind</code><span class="sig-paren">(</span><em class="sig-param">data_shapes</em>, <em class="sig-param">label_shapes=None</em>, <em class="sig-param">for_training=True</em>, <em class="sig-param">inputs_need_grad=False</em>, <em class="sig-param">force_rebind=False</em>, <em class="sig-param">shared_module=None</em>, <em class="sig-param">grad_req='write'</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/python_module.html#PythonModule.bind"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.PythonModule.bind" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Binds the symbols to construct executors. This is necessary before one |
| can perform computation with the module.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>data_shapes</strong> (<em>list of</em><em> (</em><em>str</em><em>, </em><em>tuple</em><em>)</em>) – Typically is <code class="docutils literal notranslate"><span class="pre">data_iter.provide_data</span></code>.</p></li> |
| <li><p><strong>label_shapes</strong> (<em>list of</em><em> (</em><em>str</em><em>, </em><em>tuple</em><em>)</em>) – Typically is <code class="docutils literal notranslate"><span class="pre">data_iter.provide_label</span></code>.</p></li> |
| <li><p><strong>for_training</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">True</span></code>. Whether the executors should be bind for training.</p></li> |
| <li><p><strong>inputs_need_grad</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">False</span></code>. Whether the gradients to the input data need to be computed. |
| Typically this is not needed. But this might be needed when implementing composition |
| of modules.</p></li> |
| <li><p><strong>force_rebind</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">False</span></code>. This function does nothing if the executors are already |
| bound. But with this <code class="docutils literal notranslate"><span class="pre">True</span></code>, the executors will be forced to rebind.</p></li> |
| <li><p><strong>shared_module</strong> (<a class="reference internal" href="#mxnet.module.Module" title="mxnet.module.Module"><em>Module</em></a>) – Default is <code class="docutils literal notranslate"><span class="pre">None</span></code>. This is used in bucketing. When not <code class="docutils literal notranslate"><span class="pre">None</span></code>, the shared module |
| essentially corresponds to a different bucket – a module with different symbol |
| but with the same sets of parameters (e.g. unrolled RNNs with different lengths).</p></li> |
| <li><p><strong>grad_req</strong> (<em>str</em><em>, </em><em>list of str</em><em>, </em><em>dict of str to str</em>) – Requirement for gradient accumulation. Can be ‘write’, ‘add’, or ‘null’ |
| (default to ‘write’). |
| Can be specified globally (str) or for each argument (list, dict).</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.PythonModule.data_names"> |
| <em class="property">property </em><code class="sig-name descname">data_names</code><a class="headerlink" href="#mxnet.module.PythonModule.data_names" title="Permalink to this definition">¶</a></dt> |
| <dd><p>A list of names for data required by this module.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.PythonModule.data_shapes"> |
| <em class="property">property </em><code class="sig-name descname">data_shapes</code><a class="headerlink" href="#mxnet.module.PythonModule.data_shapes" title="Permalink to this definition">¶</a></dt> |
| <dd><p>A list of (name, shape) pairs specifying the data inputs to this module.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.PythonModule.get_params"> |
| <code class="sig-name descname">get_params</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/python_module.html#PythonModule.get_params"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.PythonModule.get_params" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets parameters, those are potentially copies of the actual parameters used |
| to do computation on the device. Subclass should override this method if contains |
| parameters.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Returns</dt> |
| <dd class="field-odd"><p></p> |
| </dd> |
| <dt class="field-even">Return type</dt> |
| <dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">({},</span> <span class="pre">{})</span></code>, a pair of empty dict.</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.PythonModule.init_optimizer"> |
| <code class="sig-name descname">init_optimizer</code><span class="sig-paren">(</span><em class="sig-param">kvstore='local'</em>, <em class="sig-param">optimizer='sgd'</em>, <em class="sig-param">optimizer_params=(('learning_rate'</em>, <em class="sig-param">0.01)</em>, <em class="sig-param">)</em>, <em class="sig-param">force_init=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/python_module.html#PythonModule.init_optimizer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.PythonModule.init_optimizer" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Installs and initializes optimizers. By default we do nothing. Subclass should |
| override this method if needed.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>kvstore</strong> (<em>str</em><em> or </em><em>KVStore</em>) – Default <cite>‘local’</cite>.</p></li> |
| <li><p><strong>optimizer</strong> (<em>str</em><em> or </em><a class="reference internal" href="../optimizer/index.html#mxnet.optimizer.Optimizer" title="mxnet.optimizer.Optimizer"><em>Optimizer</em></a>) – Default <cite>‘sgd’</cite></p></li> |
| <li><p><strong>optimizer_params</strong> (<em>dict</em>) – Default <cite>((‘learning_rate’, 0.01),)</cite>. The default value is not a dictionary, |
| just to avoid pylint warning of dangerous default values.</p></li> |
| <li><p><strong>force_init</strong> (<em>bool</em>) – Default <cite>False</cite>, indicating whether we should force re-initializing the |
| optimizer in the case an optimizer is already installed.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.PythonModule.init_params"> |
| <code class="sig-name descname">init_params</code><span class="sig-paren">(</span><em class="sig-param">initializer=<mxnet.initializer.Uniform object></em>, <em class="sig-param">arg_params=None</em>, <em class="sig-param">aux_params=None</em>, <em class="sig-param">allow_missing=False</em>, <em class="sig-param">force_init=False</em>, <em class="sig-param">allow_extra=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/python_module.html#PythonModule.init_params"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.PythonModule.init_params" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Initializes the parameters and auxiliary states. By default this function |
| does nothing. Subclass should override this method if contains parameters.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>initializer</strong> (<a class="reference internal" href="../initializer/index.html#mxnet.initializer.Initializer" title="mxnet.initializer.Initializer"><em>Initializer</em></a>) – Called to initialize parameters if needed.</p></li> |
| <li><p><strong>arg_params</strong> (<em>dict</em>) – If not <code class="docutils literal notranslate"><span class="pre">None</span></code>, should be a dictionary of existing <cite>arg_params</cite>. Initialization |
| will be copied from that.</p></li> |
| <li><p><strong>aux_params</strong> (<em>dict</em>) – If not <code class="docutils literal notranslate"><span class="pre">None</span></code>, should be a dictionary of existing <cite>aux_params</cite>. Initialization |
| will be copied from that.</p></li> |
| <li><p><strong>allow_missing</strong> (<em>bool</em>) – If <code class="docutils literal notranslate"><span class="pre">True</span></code>, params could contain missing values, and the initializer will be |
| called to fill those missing params.</p></li> |
| <li><p><strong>force_init</strong> (<em>bool</em>) – If <code class="docutils literal notranslate"><span class="pre">True</span></code>, will force re-initialize even if already initialized.</p></li> |
| <li><p><strong>allow_extra</strong> (<em>boolean</em><em>, </em><em>optional</em>) – Whether allow extra parameters that are not needed by symbol. |
| If this is True, no error will be thrown when arg_params or aux_params |
| contain extra parameters that is not needed by the executor.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.PythonModule.label_shapes"> |
| <em class="property">property </em><code class="sig-name descname">label_shapes</code><a class="headerlink" href="#mxnet.module.PythonModule.label_shapes" title="Permalink to this definition">¶</a></dt> |
| <dd><p>A list of (name, shape) pairs specifying the label inputs to this module. |
| If this module does not accept labels – either it is a module without loss |
| function, or it is not bound for training, then this should return an empty |
| list <code class="docutils literal notranslate"><span class="pre">[]`</span></code>.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.PythonModule.output_names"> |
| <em class="property">property </em><code class="sig-name descname">output_names</code><a class="headerlink" href="#mxnet.module.PythonModule.output_names" title="Permalink to this definition">¶</a></dt> |
| <dd><p>A list of names for the outputs of this module.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.PythonModule.output_shapes"> |
| <em class="property">property </em><code class="sig-name descname">output_shapes</code><a class="headerlink" href="#mxnet.module.PythonModule.output_shapes" title="Permalink to this definition">¶</a></dt> |
| <dd><p>A list of (name, shape) pairs specifying the outputs of this module.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.PythonModule.update"> |
| <code class="sig-name descname">update</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/python_module.html#PythonModule.update"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.PythonModule.update" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Updates parameters according to the installed optimizer and the gradients computed |
| in the previous forward-backward batch. Currently we do nothing here. Subclass should |
| override this method if contains parameters.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.PythonModule.update_metric"> |
| <code class="sig-name descname">update_metric</code><span class="sig-paren">(</span><em class="sig-param">eval_metric</em>, <em class="sig-param">labels</em>, <em class="sig-param">pre_sliced=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/python_module.html#PythonModule.update_metric"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.PythonModule.update_metric" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Evaluates and accumulates evaluation metric on outputs of the last forward computation. |
| Subclass should override this method if needed.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>eval_metric</strong> (<a class="reference internal" href="../metric/index.html#mxnet.metric.EvalMetric" title="mxnet.metric.EvalMetric"><em>EvalMetric</em></a>) – </p></li> |
| <li><p><strong>labels</strong> (<em>list of NDArray</em>) – Typically <code class="docutils literal notranslate"><span class="pre">data_batch.label</span></code>.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| </dd></dl> |
| |
| <dl class="class"> |
| <dt id="mxnet.module.SequentialModule"> |
| <em class="property">class </em><code class="sig-prename descclassname">mxnet.module.</code><code class="sig-name descname">SequentialModule</code><span class="sig-paren">(</span><em class="sig-param">logger=<module 'logging' from '/work/conda_env/lib/python3.9/logging/__init__.py'></em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/sequential_module.html#SequentialModule"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.SequentialModule" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">mxnet.module.base_module.BaseModule</span></code></p> |
| <p>A SequentialModule is a container module that can chain multiple modules together.</p> |
| <div class="admonition note"> |
| <p class="admonition-title">Note</p> |
| <p>Building a computation graph with this kind of imperative container is less |
| flexible and less efficient than the symbolic graph. So, this should be only used as a |
| handy utility.</p> |
| </div> |
| <p><strong>Methods</strong></p> |
| <table class="longtable docutils align-default"> |
| <colgroup> |
| <col style="width: 10%" /> |
| <col style="width: 90%" /> |
| </colgroup> |
| <tbody> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.SequentialModule.add" title="mxnet.module.SequentialModule.add"><code class="xref py py-obj docutils literal notranslate"><span class="pre">add</span></code></a>(module, **kwargs)</p></td> |
| <td><p>Add a module to the chain.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.SequentialModule.backward" title="mxnet.module.SequentialModule.backward"><code class="xref py py-obj docutils literal notranslate"><span class="pre">backward</span></code></a>([out_grads])</p></td> |
| <td><p>Backward computation.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.SequentialModule.bind" title="mxnet.module.SequentialModule.bind"><code class="xref py py-obj docutils literal notranslate"><span class="pre">bind</span></code></a>(data_shapes[, label_shapes, …])</p></td> |
| <td><p>Binds the symbols to construct executors.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.SequentialModule.forward" title="mxnet.module.SequentialModule.forward"><code class="xref py py-obj docutils literal notranslate"><span class="pre">forward</span></code></a>(data_batch[, is_train])</p></td> |
| <td><p>Forward computation.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.SequentialModule.get_input_grads" title="mxnet.module.SequentialModule.get_input_grads"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_input_grads</span></code></a>([merge_multi_context])</p></td> |
| <td><p>Gets the gradients with respect to the inputs of the module.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.SequentialModule.get_outputs" title="mxnet.module.SequentialModule.get_outputs"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_outputs</span></code></a>([merge_multi_context])</p></td> |
| <td><p>Gets outputs from a previous forward computation.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.SequentialModule.get_params" title="mxnet.module.SequentialModule.get_params"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_params</span></code></a>()</p></td> |
| <td><p>Gets current parameters.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.SequentialModule.init_optimizer" title="mxnet.module.SequentialModule.init_optimizer"><code class="xref py py-obj docutils literal notranslate"><span class="pre">init_optimizer</span></code></a>([kvstore, optimizer, …])</p></td> |
| <td><p>Installs and initializes optimizers.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.SequentialModule.init_params" title="mxnet.module.SequentialModule.init_params"><code class="xref py py-obj docutils literal notranslate"><span class="pre">init_params</span></code></a>([initializer, arg_params, …])</p></td> |
| <td><p>Initializes parameters.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.SequentialModule.install_monitor" title="mxnet.module.SequentialModule.install_monitor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">install_monitor</span></code></a>(mon)</p></td> |
| <td><p>Installs monitor on all executors.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.SequentialModule.update" title="mxnet.module.SequentialModule.update"><code class="xref py py-obj docutils literal notranslate"><span class="pre">update</span></code></a>()</p></td> |
| <td><p>Updates parameters according to installed optimizer and the gradient computed in the previous forward-backward cycle.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.SequentialModule.update_metric" title="mxnet.module.SequentialModule.update_metric"><code class="xref py py-obj docutils literal notranslate"><span class="pre">update_metric</span></code></a>(eval_metric, labels[, pre_sliced])</p></td> |
| <td><p>Evaluates and accumulates evaluation metric on outputs of the last forward computation.</p></td> |
| </tr> |
| </tbody> |
| </table> |
| <p><strong>Attributes</strong></p> |
| <table class="longtable docutils align-default"> |
| <colgroup> |
| <col style="width: 10%" /> |
| <col style="width: 90%" /> |
| </colgroup> |
| <tbody> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.SequentialModule.data_names" title="mxnet.module.SequentialModule.data_names"><code class="xref py py-obj docutils literal notranslate"><span class="pre">data_names</span></code></a></p></td> |
| <td><p>A list of names for data required by this module.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.SequentialModule.data_shapes" title="mxnet.module.SequentialModule.data_shapes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">data_shapes</span></code></a></p></td> |
| <td><p>Gets data shapes.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.SequentialModule.label_shapes" title="mxnet.module.SequentialModule.label_shapes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">label_shapes</span></code></a></p></td> |
| <td><p>Gets label shapes.</p></td> |
| </tr> |
| <tr class="row-even"><td><p><a class="reference internal" href="#mxnet.module.SequentialModule.output_names" title="mxnet.module.SequentialModule.output_names"><code class="xref py py-obj docutils literal notranslate"><span class="pre">output_names</span></code></a></p></td> |
| <td><p>A list of names for the outputs of this module.</p></td> |
| </tr> |
| <tr class="row-odd"><td><p><a class="reference internal" href="#mxnet.module.SequentialModule.output_shapes" title="mxnet.module.SequentialModule.output_shapes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">output_shapes</span></code></a></p></td> |
| <td><p>Gets output shapes.</p></td> |
| </tr> |
| </tbody> |
| </table> |
| <dl class="method"> |
| <dt id="mxnet.module.SequentialModule.add"> |
| <code class="sig-name descname">add</code><span class="sig-paren">(</span><em class="sig-param">module</em>, <em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/sequential_module.html#SequentialModule.add"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.SequentialModule.add" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Add a module to the chain.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>module</strong> (<a class="reference internal" href="#mxnet.module.BaseModule" title="mxnet.module.BaseModule"><em>BaseModule</em></a>) – The new module to add.</p></li> |
| <li><p><strong>kwargs</strong> (<code class="docutils literal notranslate"><span class="pre">**keywords</span></code>) – <p>All the keyword arguments are saved as meta information |
| for the added module. The currently known meta includes</p> |
| <ul> |
| <li><dl class="simple"> |
| <dt><cite>take_labels</cite>: indicating whether the module expect to</dt><dd><p>take labels when doing computation. Note any module in |
| the chain can take labels (not necessarily only the top |
| most one), and they all take the same labels passed |
| from the original data batch for the <cite>SequentialModule</cite>.</p> |
| </dd> |
| </dl> |
| </li> |
| </ul> |
| </p></li> |
| </ul> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>This function returns <cite>self</cite> to allow us to easily chain a |
| series of <cite>add</cite> calls.</p> |
| </dd> |
| <dt class="field-odd">Return type</dt> |
| <dd class="field-odd"><p>self</p> |
| </dd> |
| </dl> |
| <p class="rubric">Examples</p> |
| <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of addinging two modules to a chain.</span> |
| <span class="gp">>>> </span><span class="n">seq_mod</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">mod</span><span class="o">.</span><span class="n">SequentialModule</span><span class="p">()</span> |
| <span class="gp">>>> </span><span class="n">seq_mod</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">mod1</span><span class="p">)</span> |
| <span class="gp">>>> </span><span class="n">seq_mod</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">mod2</span><span class="p">)</span> |
| </pre></div> |
| </div> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.SequentialModule.backward"> |
| <code class="sig-name descname">backward</code><span class="sig-paren">(</span><em class="sig-param">out_grads=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/sequential_module.html#SequentialModule.backward"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.SequentialModule.backward" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Backward computation.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.SequentialModule.bind"> |
| <code class="sig-name descname">bind</code><span class="sig-paren">(</span><em class="sig-param">data_shapes</em>, <em class="sig-param">label_shapes=None</em>, <em class="sig-param">for_training=True</em>, <em class="sig-param">inputs_need_grad=False</em>, <em class="sig-param">force_rebind=False</em>, <em class="sig-param">shared_module=None</em>, <em class="sig-param">grad_req='write'</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/sequential_module.html#SequentialModule.bind"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.SequentialModule.bind" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Binds the symbols to construct executors. This is necessary before one |
| can perform computation with the module.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>data_shapes</strong> (<em>list of</em><em> (</em><em>str</em><em>, </em><em>tuple</em><em>)</em>) – Typically is <cite>data_iter.provide_data</cite>.</p></li> |
| <li><p><strong>label_shapes</strong> (<em>list of</em><em> (</em><em>str</em><em>, </em><em>tuple</em><em>)</em>) – Typically is <cite>data_iter.provide_label</cite>.</p></li> |
| <li><p><strong>for_training</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">True</span></code>. Whether the executors should be bind for training.</p></li> |
| <li><p><strong>inputs_need_grad</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">False</span></code>. Whether the gradients to the input data need to be computed. |
| Typically this is not needed. But this might be needed when implementing composition |
| of modules.</p></li> |
| <li><p><strong>force_rebind</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">False</span></code>. This function does nothing if the executors are already |
| bound. But with this <code class="docutils literal notranslate"><span class="pre">True</span></code>, the executors will be forced to rebind.</p></li> |
| <li><p><strong>shared_module</strong> (<a class="reference internal" href="#mxnet.module.Module" title="mxnet.module.Module"><em>Module</em></a>) – Default is <code class="docutils literal notranslate"><span class="pre">None</span></code>. Currently shared module is not supported for <cite>SequentialModule</cite>.</p></li> |
| <li><p><strong>grad_req</strong> (<em>str</em><em>, </em><em>list of str</em><em>, </em><em>dict of str to str</em>) – Requirement for gradient accumulation. Can be ‘write’, ‘add’, or ‘null’ |
| (default to ‘write’). |
| Can be specified globally (str) or for each argument (list, dict).</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.SequentialModule.data_names"> |
| <em class="property">property </em><code class="sig-name descname">data_names</code><a class="headerlink" href="#mxnet.module.SequentialModule.data_names" title="Permalink to this definition">¶</a></dt> |
| <dd><p>A list of names for data required by this module.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.SequentialModule.data_shapes"> |
| <em class="property">property </em><code class="sig-name descname">data_shapes</code><a class="headerlink" href="#mxnet.module.SequentialModule.data_shapes" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets data shapes.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Returns</dt> |
| <dd class="field-odd"><p>A list of <cite>(name, shape)</cite> pairs. The data shapes of the first module |
| is the data shape of a <cite>SequentialModule</cite>.</p> |
| </dd> |
| <dt class="field-even">Return type</dt> |
| <dd class="field-even"><p>list</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.SequentialModule.forward"> |
| <code class="sig-name descname">forward</code><span class="sig-paren">(</span><em class="sig-param">data_batch</em>, <em class="sig-param">is_train=None</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/sequential_module.html#SequentialModule.forward"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.SequentialModule.forward" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Forward computation.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>data_batch</strong> (<a class="reference internal" href="../mxnet/io/index.html#mxnet.io.DataBatch" title="mxnet.io.DataBatch"><em>DataBatch</em></a>) – </p></li> |
| <li><p><strong>is_train</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">None</span></code>, in which case <cite>is_train</cite> is take as <code class="docutils literal notranslate"><span class="pre">self.for_training</span></code>.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.SequentialModule.get_input_grads"> |
| <code class="sig-name descname">get_input_grads</code><span class="sig-paren">(</span><em class="sig-param">merge_multi_context=True</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/sequential_module.html#SequentialModule.get_input_grads"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.SequentialModule.get_input_grads" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets the gradients with respect to the inputs of the module.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>merge_multi_context</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">True</span></code>. In the case when data-parallelism is used, the outputs |
| will be collected from multiple devices. A <code class="docutils literal notranslate"><span class="pre">True</span></code> value indicate that we |
| should merge the collected results so that they look like from a single |
| executor.</p> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>If <cite>merge_multi_context</cite> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, it is like <code class="docutils literal notranslate"><span class="pre">[grad1,</span> <span class="pre">grad2]</span></code>. Otherwise, it |
| is like <code class="docutils literal notranslate"><span class="pre">[[grad1_dev1,</span> <span class="pre">grad1_dev2],</span> <span class="pre">[grad2_dev1,</span> <span class="pre">grad2_dev2]]</span></code>. All the output |
| elements are <cite>NDArray</cite>.</p> |
| </dd> |
| <dt class="field-odd">Return type</dt> |
| <dd class="field-odd"><p>list of NDArrays or list of list of NDArrays</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.SequentialModule.get_outputs"> |
| <code class="sig-name descname">get_outputs</code><span class="sig-paren">(</span><em class="sig-param">merge_multi_context=True</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/sequential_module.html#SequentialModule.get_outputs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.SequentialModule.get_outputs" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets outputs from a previous forward computation.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><p><strong>merge_multi_context</strong> (<em>bool</em>) – Default is <code class="docutils literal notranslate"><span class="pre">True</span></code>. In the case when data-parallelism is used, the outputs |
| will be collected from multiple devices. A <code class="docutils literal notranslate"><span class="pre">True</span></code> value indicate that we |
| should merge the collected results so that they look like from a single |
| executor.</p> |
| </dd> |
| <dt class="field-even">Returns</dt> |
| <dd class="field-even"><p>If <cite>merge_multi_context</cite> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, it is like <code class="docutils literal notranslate"><span class="pre">[out1,</span> |
| <span class="pre">out2]</span></code>. Otherwise, it is like <code class="docutils literal notranslate"><span class="pre">[[out1_dev1,</span> <span class="pre">out1_dev2],</span> <span class="pre">[out2_dev1,</span> |
| <span class="pre">out2_dev2]]</span></code>. All the output elements are numpy arrays.</p> |
| </dd> |
| <dt class="field-odd">Return type</dt> |
| <dd class="field-odd"><p>list of NDArray or list of list of NDArray</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.SequentialModule.get_params"> |
| <code class="sig-name descname">get_params</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/sequential_module.html#SequentialModule.get_params"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.SequentialModule.get_params" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets current parameters.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Returns</dt> |
| <dd class="field-odd"><p>A pair of dictionaries each mapping parameter names to NDArray values. This |
| is a merged dictionary of all the parameters in the modules.</p> |
| </dd> |
| <dt class="field-even">Return type</dt> |
| <dd class="field-even"><p>(arg_params, aux_params)</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.SequentialModule.init_optimizer"> |
| <code class="sig-name descname">init_optimizer</code><span class="sig-paren">(</span><em class="sig-param">kvstore='local'</em>, <em class="sig-param">optimizer='sgd'</em>, <em class="sig-param">optimizer_params=(('learning_rate'</em>, <em class="sig-param">0.01)</em>, <em class="sig-param">)</em>, <em class="sig-param">force_init=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/sequential_module.html#SequentialModule.init_optimizer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.SequentialModule.init_optimizer" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Installs and initializes optimizers.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>kvstore</strong> (<em>str</em><em> or </em><em>KVStore</em>) – Default <cite>‘local’</cite>.</p></li> |
| <li><p><strong>optimizer</strong> (<em>str</em><em> or </em><a class="reference internal" href="../optimizer/index.html#mxnet.optimizer.Optimizer" title="mxnet.optimizer.Optimizer"><em>Optimizer</em></a>) – Default <cite>‘sgd’</cite></p></li> |
| <li><p><strong>optimizer_params</strong> (<em>dict</em>) – Default <code class="docutils literal notranslate"><span class="pre">(('learning_rate',</span> <span class="pre">0.01),)</span></code>. The default value is not a dictionary, |
| just to avoid pylint warning of dangerous default values.</p></li> |
| <li><p><strong>force_init</strong> (<em>bool</em>) – Default <code class="docutils literal notranslate"><span class="pre">False</span></code>, indicating whether we should force re-initializing the |
| optimizer in the case an optimizer is already installed.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.SequentialModule.init_params"> |
| <code class="sig-name descname">init_params</code><span class="sig-paren">(</span><em class="sig-param">initializer=<mxnet.initializer.Uniform object></em>, <em class="sig-param">arg_params=None</em>, <em class="sig-param">aux_params=None</em>, <em class="sig-param">allow_missing=False</em>, <em class="sig-param">force_init=False</em>, <em class="sig-param">allow_extra=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/sequential_module.html#SequentialModule.init_params"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.SequentialModule.init_params" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Initializes parameters.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>initializer</strong> (<a class="reference internal" href="../initializer/index.html#mxnet.initializer.Initializer" title="mxnet.initializer.Initializer"><em>Initializer</em></a>) – </p></li> |
| <li><p><strong>arg_params</strong> (<em>dict</em>) – Default <code class="docutils literal notranslate"><span class="pre">None</span></code>. Existing parameters. This has higher priority |
| than <cite>initializer</cite>.</p></li> |
| <li><p><strong>aux_params</strong> (<em>dict</em>) – Default <code class="docutils literal notranslate"><span class="pre">None</span></code>. Existing auxiliary states. This has higher priority |
| than <cite>initializer</cite>.</p></li> |
| <li><p><strong>allow_missing</strong> (<em>bool</em>) – Allow missing values in <cite>arg_params</cite> and <cite>aux_params</cite> (if not <code class="docutils literal notranslate"><span class="pre">None</span></code>). |
| In this case, missing values will be filled with <cite>initializer</cite>.</p></li> |
| <li><p><strong>force_init</strong> (<em>bool</em>) – Default <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p></li> |
| <li><p><strong>allow_extra</strong> (<em>boolean</em><em>, </em><em>optional</em>) – Whether allow extra parameters that are not needed by symbol. |
| If this is True, no error will be thrown when arg_params or aux_params |
| contain extra parameters that is not needed by the executor.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.SequentialModule.install_monitor"> |
| <code class="sig-name descname">install_monitor</code><span class="sig-paren">(</span><em class="sig-param">mon</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/sequential_module.html#SequentialModule.install_monitor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.SequentialModule.install_monitor" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Installs monitor on all executors.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.SequentialModule.label_shapes"> |
| <em class="property">property </em><code class="sig-name descname">label_shapes</code><a class="headerlink" href="#mxnet.module.SequentialModule.label_shapes" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets label shapes.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Returns</dt> |
| <dd class="field-odd"><p>A list of <cite>(name, shape)</cite> pairs. The return value could be <cite>None</cite> if |
| the module does not need labels, or if the module is not bound for |
| training (in this case, label information is not available).</p> |
| </dd> |
| <dt class="field-even">Return type</dt> |
| <dd class="field-even"><p>list</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.SequentialModule.output_names"> |
| <em class="property">property </em><code class="sig-name descname">output_names</code><a class="headerlink" href="#mxnet.module.SequentialModule.output_names" title="Permalink to this definition">¶</a></dt> |
| <dd><p>A list of names for the outputs of this module.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.SequentialModule.output_shapes"> |
| <em class="property">property </em><code class="sig-name descname">output_shapes</code><a class="headerlink" href="#mxnet.module.SequentialModule.output_shapes" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Gets output shapes.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Returns</dt> |
| <dd class="field-odd"><p>A list of <cite>(name, shape)</cite> pairs. The output shapes of the last |
| module is the output shape of a <cite>SequentialModule</cite>.</p> |
| </dd> |
| <dt class="field-even">Return type</dt> |
| <dd class="field-even"><p>list</p> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.SequentialModule.update"> |
| <code class="sig-name descname">update</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/sequential_module.html#SequentialModule.update"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.SequentialModule.update" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Updates parameters according to installed optimizer and the gradient computed |
| in the previous forward-backward cycle.</p> |
| </dd></dl> |
| |
| <dl class="method"> |
| <dt id="mxnet.module.SequentialModule.update_metric"> |
| <code class="sig-name descname">update_metric</code><span class="sig-paren">(</span><em class="sig-param">eval_metric</em>, <em class="sig-param">labels</em>, <em class="sig-param">pre_sliced=False</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mxnet/module/sequential_module.html#SequentialModule.update_metric"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mxnet.module.SequentialModule.update_metric" title="Permalink to this definition">¶</a></dt> |
| <dd><p>Evaluates and accumulates evaluation metric on outputs of the last forward computation.</p> |
| <dl class="field-list simple"> |
| <dt class="field-odd">Parameters</dt> |
| <dd class="field-odd"><ul class="simple"> |
| <li><p><strong>eval_metric</strong> (<a class="reference internal" href="../metric/index.html#mxnet.metric.EvalMetric" title="mxnet.metric.EvalMetric"><em>EvalMetric</em></a>) – </p></li> |
| <li><p><strong>labels</strong> (<em>list of NDArray</em>) – Typically <code class="docutils literal notranslate"><span class="pre">data_batch.label</span></code>.</p></li> |
| </ul> |
| </dd> |
| </dl> |
| </dd></dl> |
| |
| </dd></dl> |
| |
| </div> |
| |
| |
| <hr class="feedback-hr-top" /> |
| <div class="feedback-container"> |
| <div class="feedback-question">Did this page help you?</div> |
| <div class="feedback-answer-container"> |
| <div class="feedback-answer yes-link" data-response="yes">Yes</div> |
| <div class="feedback-answer no-link" data-response="no">No</div> |
| </div> |
| <div class="feedback-thank-you">Thanks for your feedback!</div> |
| </div> |
| <hr class="feedback-hr-bottom" /> |
| </div> |
| <div class="side-doc-outline"> |
| <div class="side-doc-outline--content"> |
| </div> |
| </div> |
| |
| <div class="clearer"></div> |
| </div><div class="pagenation"> |
| <a id="button-prev" href="../symbol/sparse/index.html" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--colored" role="botton" accesskey="P"> |
| <i class="pagenation-arrow-L fas fa-arrow-left fa-lg"></i> |
| <div class="pagenation-text"> |
| <span class="pagenation-direction">Previous</span> |
| <div>symbol.sparse</div> |
| </div> |
| </a> |
| <a id="button-next" href="../contrib/index.html" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--colored" role="botton" accesskey="N"> |
| <i class="pagenation-arrow-R fas fa-arrow-right fa-lg"></i> |
| <div class="pagenation-text"> |
| <span class="pagenation-direction">Next</span> |
| <div>mxnet.contrib</div> |
| </div> |
| </a> |
| </div> |
| <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 class="u-email" href="mailto:dev@mxnet.apache.org">Dev list</a></li> |
| <li><a class="u-email" href="mailto:user@mxnet.apache.org">User mailing list</a></li> |
| <li><a href="https://cwiki.apache.org/confluence/display/MXNET/Apache+MXNet+Home">Developer Wiki</a></li> |
| <li><a href="https://issues.apache.org/jira/projects/MXNET/issues">Jira Tracker</a></li> |
| <li><a href="https://github.com/apache/incubator-mxnet/labels/Roadmap">Github Roadmap</a></li> |
| <li><a href="https://discuss.mxnet.io">MXNet Discuss forum</a></li> |
| <li><a href="/community/contribute">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="../../_static/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="../../_static/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="../../_static/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="../../_static/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> |