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

Fix crashes on visualization #14425

Merged
merged 5 commits into from
Mar 18, 2019
Merged

Fix crashes on visualization #14425

merged 5 commits into from
Mar 18, 2019

Conversation

vandanavk
Copy link
Contributor

@vandanavk vandanavk commented Mar 14, 2019

Description

Fixes #14245
Fixes #10416

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Add a check for the presence of kernel in attrs

Comments

Test code for Pooling visualization crash (after fix):

import mxnet as mx
data=mx.sym.Variable('data')
symbol = mx.sym.Pooling(data = data, global_pool = True, pool_type = 'avg')
graph = mx.viz.plot_network(symbol)
graph

image

Test code for LeakyRelu visualization crash (after fix):

import mxnet as mx
data=mx.sym.Variable('data')
symbol = mx.sym.LeakyReLU(data=data)
graph = mx.viz.plot_network(symbol)
graph

image

Test after changing to str.format:

import mxnet as mx
data=mx.sym.Variable('data')
symbol = mx.sym.Convolution(data=data, kernel=(3,3), stride=(1,1), num_filter=3)
graph = mx.viz.plot_network(symbol)
graph

image

import mxnet as mx
data=mx.sym.Variable('data')
symbol = mx.sym.FullyConnected(data=data, num_hidden=3)
graph = mx.viz.plot_network(symbol)
graph

image

Change in print_summary tested with

nosetests tests/python/unittest/test_viz.py:test_print_summary
.
----------------------------------------------------------------------
Ran 1 test in 0.015s

OK

@vandanavk vandanavk requested a review from szha as a code owner March 14, 2019 01:37
@vandanavk
Copy link
Contributor Author

@mxnet-label-bot add [Visualization, pr-awaiting-review]

@marcoabreu marcoabreu added pr-awaiting-review PR is waiting for code review Visualization labels Mar 14, 2019
@vandanavk vandanavk changed the title Check for kernel in Pooling Check for kernel in Pooling (Visualization) Mar 14, 2019
@vandanavk vandanavk changed the title Check for kernel in Pooling (Visualization) Fix crashes on visualization Mar 14, 2019
@vandanavk
Copy link
Contributor Author

Test for plot network has been disabled in the code

@unittest.skipIf(not graphviz_exists(), "Skip test_plot_network as Graphviz could not be imported")
def test_plot_network():

@@ -339,11 +339,17 @@ def looks_like_weight(name):
elif op == "BatchNorm":
attr["fillcolor"] = cm[3]
elif op in ('Activation', 'LeakyReLU'):
label = r"%s\n%s" % (op, node["attrs"]["act_type"])
if op == "LeakyReLU":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if special handling is needed for each case, then the outer elif op in ... is not necessary.

act_type = attrs.get("act_type", "Leaky") if attrs else "Leaky"
else:
act_type = node["attrs"]["act_type"]
label = r"%s\n%s" % (op, str(act_type))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this usage is being deprecated. use string.format instead.

@vandanavk
Copy link
Contributor Author

vandanavk commented Mar 14, 2019

@szha All review comments addressed. Details of tests are in the PR description

Copy link
Member

@wkcn wkcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! LGTM: )

@wkcn wkcn merged commit ab5b44c into apache:master Mar 18, 2019
@wkcn
Copy link
Member

wkcn commented Mar 18, 2019

The PR has been merged. Thank you again! : )

vdantu pushed a commit to vdantu/incubator-mxnet that referenced this pull request Mar 31, 2019
* Check for kernel in Pooling

* Fix Leakyrelu visualization

* Address review comments

* Change all occurences to string format

* Fix lint error
nswamy pushed a commit that referenced this pull request Apr 5, 2019
* Check for kernel in Pooling

* Fix Leakyrelu visualization

* Address review comments

* Change all occurences to string format

* Fix lint error
haohuanw pushed a commit to haohuanw/incubator-mxnet that referenced this pull request Jun 23, 2019
* Check for kernel in Pooling

* Fix Leakyrelu visualization

* Address review comments

* Change all occurences to string format

* Fix lint error
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr-awaiting-review PR is waiting for code review Visualization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

visualize with global_pooling and no kernel crashes. mx.symbol.LeakyRelu could not be visualized
4 participants