You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/05/01 19:34:28 UTC

[GitHub] luoyetx opened a new issue #10695: SymbolBlock has no `_reg_params` which cause save/load params fails

luoyetx opened a new issue #10695: SymbolBlock has no `_reg_params` which cause save/load params fails
URL: https://github.com/apache/incubator-mxnet/issues/10695
 
 
   ## Description
   block with symbol block as child doesn't save/load symbol block's parameters.
   
   ## Environment info (Required)
   
   mxnet==1.2.0b20180425
   
   ## Steps to reproduce
   
   ```python
   import mxnet as mx
   from mxnet import gluon as gl, nd
   from mxnet.gluon import nn
   
   
   class Net(gl.HybridBlock):
       def __init__(self):
           super(Net, self).__init__()
           with self.name_scope():
               backbone = gl.model_zoo.vision.resnet50_v1()
               data = mx.sym.var('data')
               featnames = ['stage1_activation2', 'stage2_activation3', 'stage3_activation5']
               out_names = ['_'.join([backbone.name, featname, 'output']) for featname in featnames]
               internals = backbone(data).get_internals()
               outs = [internals[out_name] for out_name in out_names]
               self.backbone = gl.SymbolBlock(outs, data, params=backbone.collect_params())
               self.body = nn.Conv2D(3, 1)
               
       def hybrid_forward(self, F, x):
           x = self.body(x)
           return self.backbone(x)
       
   ctx = mx.cpu()
   net = Net()
   net.initialize(mx.init.Normal(), ctx=ctx)
   net.hybridize()
   
   net(nd.random.normal(shape=(1, 3, 224, 224)))
   net.save_params('./test.params')
   for k, v in nd.load('./test.params').items():
       print(k)
   
   for k, v in net.collect_params().items():
       print(k)
   ```
   
   ## What have you tried to solve it?
   
   add `_reg_params` to symbol block solves this problem.
   
   ```python
   self._reg_params = self._params
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services