Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
```
$ 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'>)
)
>>>
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.