zhanghang1989 opened a new issue #10544: name_scope/prefix doesn't work
URL: https://github.com/apache/incubator-mxnet/issues/10544
 
 
   ## Description
   
   name_scope/prefix doesn't work
   @piiswrong 
   
   ## Minimum reproducible example
   
   ```python
   import gluonvision
   net = gluonvision.model_zoo.FCN(10)
   net2 = gluonvision.model_zoo.FCN(10)
   net.save_params('test.params') 
   net2.load_params('test.params')
   ```
   
   ## Error Message:
   (Paste the complete error message, including stack trace.)
   
   ```bash
   ---------------------------------------------------------------------------
   TypeError                                 Traceback (most recent call last)
   <ipython-input-1-9fe44f517b3a> in <module>()
         4 net2 = gluonvision.model_zoo.FCN(10)
         5 net.save_params('test.params')
   ----> 6 net2.load_params('test.params')
   
   
~/anaconda3/lib/python3.6/site-packages/mxnet-1.2.0-py3.6.egg/mxnet/gluon/block.py
 in load_params(self, filename, ctx, allow_missing, ignore_extra)
       316         """
       317         self.collect_params().load(filename, ctx, allow_missing, 
ignore_extra,
   --> 318                                    self.prefix)
       319 
       320     def register_child(self, block):
   
   
~/anaconda3/lib/python3.6/site-packages/mxnet-1.2.0-py3.6.egg/mxnet/gluon/parameter.py
 in load(self, filename, ctx, allow_missing, ignore_extra, restore_prefix)
       775                     "Parameter '%s' is missing in file '%s', which 
contains parameters: %s. " \
       776                     "Please make sure source and target networks 
have the same prefix."%(
   --> 777                         name[lprefix:], filename, 
_brief_print_list(arg_dict.keys()))
       778         for name in arg_dict:
       779             if name not in self._params:
   
   
~/anaconda3/lib/python3.6/site-packages/mxnet-1.2.0-py3.6.egg/mxnet/gluon/parameter.py
 in _brief_print_list(lst, limit)
       502     """Print at most `limit` elements of list."""
       503     if len(lst) > limit:
   --> 504         return _brief_print_list(lst[:limit//2], limit) + ', ..., ' 
+ \
       505             _brief_print_list(lst[-limit//2:], limit)
       506     return ', '.join(["'%s'"%str(i) for i in lst])
   
   TypeError: 'dict_keys' object is not subscriptable
   ```
   
   ## other output
   ```python
   import mxnet as mx
   params = mx.nd.load('test.params')
   for key, val in params.items():
       print (key)      
   ```
   Terminal ourputs:
   ```bash
   ......
   fcn0__fcnhead0_batchnorm0_gamma
   fcn0__fcnhead0_batchnorm0_beta
   fcn0__fcnhead0_batchnorm0_running_mean
   fcn0__fcnhead0_batchnorm0_running_var
   fcn0__fcnhead0_conv0_weight
   fcn0__fcnhead0_conv0_bias
   fcn0__fcnhead0_batchnorm1_gamma
   fcn0__fcnhead0_batchnorm1_beta
   fcn0__fcnhead0_batchnorm1_running_mean
   fcn0__fcnhead0_batchnorm1_running_var
   fcn0__fcnhead0_conv1_weight
   fcn0__fcnhead0_conv1_bias
   ```

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to