-
Notifications
You must be signed in to change notification settings - Fork 6.8k
[MXNET-210]give warning for variables with same name in graph visualization #10429
Conversation
python/mxnet/visualization.py
Outdated
@@ -252,6 +252,10 @@ def plot_network(symbol, title="plot", save_format='pdf', shape=None, node_attrs | |||
shape_dict = dict(zip(interals.list_outputs(), out_shapes)) | |||
conf = json.loads(symbol.tojson()) | |||
nodes = conf["nodes"] | |||
# check if multiple nodes have the same name | |||
if len(nodes) != len(set([node["name"] for node in nodes])): | |||
logging.warning("There are multiple variables with the same name in your graph, " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would good to print the duplicate name in your warning message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the change.
@reminisce - Can you please take a look at this?
@reminisce @eric-haibin-lin Can somebody review and merge if its okay? |
python/mxnet/visualization.py
Outdated
@@ -252,6 +252,15 @@ def plot_network(symbol, title="plot", save_format='pdf', shape=None, node_attrs | |||
shape_dict = dict(zip(interals.list_outputs(), out_shapes)) | |||
conf = json.loads(symbol.tojson()) | |||
nodes = conf["nodes"] | |||
# check if multiple nodes have the same name | |||
if len(nodes) != len(set([node["name"] for node in nodes])): | |||
seen = set() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seen_nodes
python/mxnet/visualization.py
Outdated
# check if multiple nodes have the same name | ||
if len(nodes) != len(set([node["name"] for node in nodes])): | ||
seen = set() | ||
seen_add = seen.add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why need to define this?
Could you add a unit test? I think in Python you can assert warnings. |
@marcoabreu I am adding a unit test which require graphviz, may I know where shall I configure that in CI for Windows? Thanks |
Hello, I'm afraid we're not able to change the Windows environment as of now. For now, please use a try-catch and skip if the import failed. |
2d276c0
to
2857a10
Compare
please resolve conflicts |
@roywei ping |
@eric-haibin-lin @szha resolved conflicts, and finally CI passed. |
…zation (apache#10429) * give warning for variables with same name in graph visualization * fix line too long * print repetead node names * update warning and unit test * add assert for repeated node * add graphviz for arm * update docker install * skip unittest if graphviz could not be imported * optimize imports
Description
Issue 9898
MXNet allow to use same name for variables, it could cause confusion
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Comments