2

I am trying to visualize the neural network graph created by using mxnet inn python. The code is shown below

net = mx.sym.Variable('data')    
net = mx.sym.FullyConnected(data=net, name='fc1', num_hidden=128)    
net = mx.sym.Activation(data=net, name='relu1', act_type="relu")    
net = mx.sym.FullyConnected(data=net, name='fc2', num_hidden=10)    
net = mx.sym.SoftmaxOutput(data=net, name='out')    
mx.viz.plot_network(net, shape={'data':(100,200)})  

The last line runs without any error and I see this message - graphviz.dot.Digraph at 0x262f91b8e10>

But I do not see any graph. Please note that I have installed graphviz.

Abhishek Kishore
  • 340
  • 2
  • 13
  • According to [this example](http://josephpcohen.com/w/visualizing-cnn-architectures-side-by-side-with-mxnet/), you may need to save the `graphviz.dot.Digraph` to a variable (let's call it `a`), then call `a.render()`. – unutbu Feb 27 '17 at 18:30
  • Are you running this in a jupyter notebook? – Leopd Feb 27 '17 at 21:58
  • 1
    I had to add the graphviz binaries path in my PATH environment variable and as suggested by unubtu I called a.render() which created a pdf file with the graph in it. Yes, I am using jupyter notebook Leopd – Abhishek Kishore Feb 28 '17 at 18:14
  • @AbhishekKishore if you have found a fix, can you please post it as an answer? It will remove this question from the answered pool and might help others too. – lynguyen Jun 16 '17 at 23:37

2 Answers2

1

I'm not sure if this is your problem or not. But in Ubuntu at least you need to install graphviz twice: both as a stand-alone package, and also the python bindings separately.

sudo apt-get install -y graphviz
sudo pip install graphviz

If you do all that, and you're in a jupyter notebook, the graphviz object has a method exposed (I forget what it's called) that jupyter introspects and calls to render the drawing.

If you're in a command-line ipython or python shell it of course won't render the drawing, because it can't render graphics.

Leopd
  • 41,333
  • 31
  • 129
  • 167
0

I had to add the graphviz binaries path in my PATH environment variable and as suggested by unubtu I called a.render() which created a pdf file with the graph in it.

Abhishek Gurjar
  • 7,426
  • 10
  • 37
  • 45
Abhishek Kishore
  • 340
  • 2
  • 13