Conversation
|
@mxnet-label-bot add [Gluon, pr-awaiting-review] |
szha
left a comment
There was a problem hiding this comment.
Could you add a test? Also, what does the current string representation look like, for example for alexnet?
|
+1 on szha's comment |
|
Thanks for inputs @szha @eric-haibin-lin. Added an example in the PR description. Will add a test and submit shortly |
|
@szha @eric-haibin-lin added a test in test_import() of test_gluon.py |
python/mxnet/gluon/block.py
Outdated
|
|
||
| def __repr__(self): | ||
| s = '{name}(\n{modstr}\n)' | ||
| modstr = '\n'.join(['{block}'.format(block=self.__dict__['_cached_graph'][-1])]) |
There was a problem hiding this comment.
would it be more useful to show also the input count and output count?
There was a problem hiding this comment.
corrected dict to self._cached_graph.
-1 index as the last element of cached_graph is the output. I could have used cached_graph[1], but did not want to hit index out of bounds (in case it ever happens).
There was a problem hiding this comment.
I think showing all layers like how HybridSequential prints, would be most useful, but not sure how to do that for Symbol API and SymbolBlock models.
There was a problem hiding this comment.
Printing the inner structure might be too complicated and also not readable, thus I suggested printing the count.
Why would cached_graph[1] ever hit index out of bounds?
There was a problem hiding this comment.
something like this?
SymbolBlock(
<Symbol dense1_fwd>
)
Number of inputs: 1
Number of outputs: 1
There was a problem hiding this comment.
@szha thanks for the inputs. submitted after addressing the comments. Added an example of multiple outputs in the PR description
wkcn
left a comment
There was a problem hiding this comment.
Thanks for your contribution! LGTM
I think the test case Is too strict. We can use 'in' to test it.
|
@wkcn Do you mean lines[0] check? I did something similar to https://github.com/apache/incubator-mxnet/blob/a6a4fe188d4847a608952fb69ff68e7ab91c5050/tests/python/unittest/test_gluon.py#L237 |
* Add repr for SymbolBlock * Add a test * Correct self.cached_graph * Address review comments
* Add repr for SymbolBlock * Add a test * Correct self.cached_graph * Address review comments
* Add repr for SymbolBlock * Add a test * Correct self.cached_graph * Address review comments
Description
SymbolBlock uses
Block.__repr__whenprint(SymbolBlock)is executed. InBlock.__repr__, data is printed only if it is of type Block. Adding a__repr__to SymbolBlock class that prints the output symbol. This behavior is similar to printing pure Symbol API.Fixes #13616
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Executing
gives the output
Before
After change
Example with a model with more than one output:
Output:
Comments
@eric-haibin-lin @Ishitori