Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Fix __repr__ for gluon.Parameter #8956

Merged
merged 3 commits into from
Dec 9, 2017

Conversation

JulianSlzr
Copy link
Contributor

@JulianSlzr JulianSlzr commented Dec 5, 2017

Description

Printing gluon.Parameter (__repr__) gives an error; this resolves the issue.

Checklist

Essentials

  • Passed code style checking (make lint)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage
  • [n/a] For user-facing API changes, API doc string has been updated. For new C++ functions in header files, their functionalities and arguments are well-documented.
  • To my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Update gluon.Parameter.__repr__

Comments

Printing any gluon.parameters (e.g., print(net.collect_params())) will give:

.../site-packages/mxnet/gluon/parameter.py", line 120, in __repr__
    return s.format(**self.__dict__)
KeyError: 'shape'

instead of

model0_ (
...
  Parameter model0_dense1_weight (shape=(10, 0), dtype=<class 'numpy.float32'>)
  Parameter model0_dense1_bias (shape=(10,), dtype=<class 'numpy.float32'>)
)

This regression in 1.0.0 due to this change, though __repr__ was also at fault for using self.__dict__ directly instead of the properties.

JulianSlzr added a commit to JulianSlzr/incubator-mxnet that referenced this pull request Dec 5, 2017
@piiswrong
Copy link
Contributor

Please add an unittest for printing

JulianSlzr added a commit to JulianSlzr/incubator-mxnet that referenced this pull request Dec 6, 2017
@JulianSlzr
Copy link
Contributor Author

Wrote test and rebased, should be good now

@piiswrong piiswrong merged commit d77d937 into apache:master Dec 9, 2017
@JulianSlzr JulianSlzr deleted the gluon-parameter-repr branch December 9, 2017 02:18
cjolivier01 pushed a commit to cjolivier01/mxnet that referenced this pull request Dec 10, 2017
* Fix __repr__ for gluon.parameter

* Add to contributors (PRs apache#8565, apache#8956, etc.)

* Add unit test for gluon.Parameter string
szha pushed a commit that referenced this pull request Dec 14, 2017
* Fix __repr__ for gluon.parameter

* Add to contributors (PRs #8565, #8956, etc.)

* Add unit test for gluon.Parameter string
rahul003 pushed a commit to rahul003/mxnet that referenced this pull request Jun 4, 2018
* Fix __repr__ for gluon.parameter

* Add to contributors (PRs apache#8565, apache#8956, etc.)

* Add unit test for gluon.Parameter string
zheng-da pushed a commit to zheng-da/incubator-mxnet that referenced this pull request Jun 28, 2018
* Fix __repr__ for gluon.parameter

* Add to contributors (PRs apache#8565, apache#8956, etc.)

* Add unit test for gluon.Parameter string
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants