JulianSlzr opened a new pull request #8956: Fix __repr__ for gluon.Parameter
URL: https://github.com/apache/incubator-mxnet/pull/8956
 
 
   ## Description ##
   Printing `gluon.Parameter` (`__repr__`) gives an error; this resolves the 
issue.
   
   ## Checklist ##
   ### Essentials ###
   - [x] Passed code style checking (`make lint`)
   - [x] Changes are complete (i.e. I finished coding on this PR)
   - [n/a] 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. 
   - [x] To my best knowledge, examples are either not affected by this change, 
or have been fixed to be compatible with this change
   
   ### Changes ###
   - [x] 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](https://github.com/apache/incubator-mxnet/commit/1852e2f47d68bb4c2373a359a2a8671b59cd14e5#diff-89ace34cda0f147e8dd6010b0a19be90R110),
 though `__repr__` was also at fault for using `self.__dict__` directly instead 
of the properties.
   

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to