mrkn opened a new pull request #10515: Prevent partially update of ParameterDict
URL: https://github.com/apache/incubator-mxnet/pull/10515
 
 
   As you can see in the following execution log, 
`mxnet.gluon.parameter.ParameterDict#update` method partially updates the 
receiver when the assertion error is occurred by duplicated keys.
   Is this intentional processing?
   
   ```
   $ python
   Python 3.6.4 (default, Apr  3 2018, 09:35:44)
   [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
   Type "help", "copyright", "credits" or "license" for more information.
   >>> from mxnet.gluon.parameter import ParameterDict
   >>> pd1 = ParameterDict()
   >>> pd2 = ParameterDict()
   >>> pd1.get('a')
   Parameter a (shape=None, dtype=<class 'numpy.float32'>)
   >>> pd1.get('b')
   Parameter b (shape=None, dtype=<class 'numpy.float32'>)
   >>> pd1.get('c')
   Parameter c (shape=None, dtype=<class 'numpy.float32'>)
   >>> pd2.get('d')
   Parameter d (shape=None, dtype=<class 'numpy.float32'>)
   >>> pd2.get('b')
   Parameter b (shape=None, dtype=<class 'numpy.float32'>)
   >>> pd2.get('e')
   Parameter e (shape=None, dtype=<class 'numpy.float32'>)
   >>> pd1
   (
     Parameter a (shape=None, dtype=<class 'numpy.float32'>)
     Parameter b (shape=None, dtype=<class 'numpy.float32'>)
     Parameter c (shape=None, dtype=<class 'numpy.float32'>)
   )
   >>> pd2
   (
     Parameter d (shape=None, dtype=<class 'numpy.float32'>)
     Parameter b (shape=None, dtype=<class 'numpy.float32'>)
     Parameter e (shape=None, dtype=<class 'numpy.float32'>)
   )
   >>> pd1.update(pd2)
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File 
"/Users/mrkn/.pyenv/versions/3.6.4/Python.framework/Versions/3.6/lib/python3.6/site-packages/mxnet/gluon/parameter.py",
 line 557, in update
       "Parameters with the same name %s"%k
   AssertionError: Cannot update self with other because they have different 
Parameters with the same name b
   >>> pd1
   (
     Parameter a (shape=None, dtype=<class 'numpy.float32'>)
     Parameter b (shape=None, dtype=<class 'numpy.float32'>)
     Parameter c (shape=None, dtype=<class 'numpy.float32'>)
     Parameter d (shape=None, dtype=<class 'numpy.float32'>)
   )
   >>>
   ```

----------------------------------------------------------------
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