You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by zh...@apache.org on 2020/09/01 20:59:16 UTC

[incubator-mxnet] branch master updated: fix block.export (#17970)

This is an automated email from the ASF dual-hosted git repository.

zhasheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new 5122d32  fix block.export (#17970)
5122d32 is described below

commit 5122d322c8529493652e3fdf4304265cf4f1f09c
Author: chinakook <ch...@msn.com>
AuthorDate: Wed Sep 2 04:58:09 2020 +0800

    fix block.export (#17970)
    
    * fix block.export
    
    ```net.hybridize``` may optimize out some ops. These ops are alive in nn.Block(also nn.HybridBlock), but its names are not contained in symbol's ```arg_names``` list. So ignore these ops except that their name are end with 'running_mean' or 'running_var'.
    
    * Update block.py
    
    let user can save their extra param.
    
    * add allow_extra
    
    add allow_extra to let user decide whether to save extra parameters or not.
    
    * Update block.py
    
    add moving_mean and moving_var when export model with SymbolBlock
    
    * Update python/mxnet/gluon/block.py
    
    typo
    
    Co-authored-by: Sheng Zha <sz...@users.noreply.github.com>
    
    * Update block.py
    
    * Update block.py
    
    * Update python/mxnet/gluon/block.py
    
    Co-authored-by: Leonard Lausen <le...@lausen.nl>
    
    Co-authored-by: Sheng Zha <sz...@users.noreply.github.com>
    Co-authored-by: Leonard Lausen <le...@lausen.nl>
---
 python/mxnet/gluon/block.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/python/mxnet/gluon/block.py b/python/mxnet/gluon/block.py
index be98b7a..0a1c758 100644
--- a/python/mxnet/gluon/block.py
+++ b/python/mxnet/gluon/block.py
@@ -1348,8 +1348,11 @@ class HybridBlock(Block):
                 if name in arg_names:
                     arg_dict['arg:{}'.format(name)] = param._reduce()
                 else:
-                    assert name in aux_names
-                    arg_dict['aux:{}'.format(name)] = param._reduce()
+                    if name not in aux_names:
+                        warnings.warn('Parameter "{name}" is not found in the graph. '
+                                      .format(name=name), stacklevel=3)
+                    else:
+                        arg_dict['aux:%s'%name] = param._reduce()
         save_fn = _mx_npx.save if is_np_array() else ndarray.save
         params_filename = '%s-%04d.params'%(path, epoch)
         save_fn(params_filename, arg_dict)