Plotting gluon hybrid network

Hi there,

I try to visualise an SSD network from GluonCV, using the function:

import gluoncv

net_name = 'ssd_512_resnet18_v1_voc'
net = gluoncv.model_zoo.get_model(net_name, pretrained_base=True)
gluoncv.utils.viz.plot_network(net, shape=(1, 3, 512, 512))

It gives an error:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Users/blake/.local/share/virtualenvs/vocssd-E4rsV6CG/lib/python3.7/site-packages/gluoncv/utils/viz/", line 32, in plot_network
    node_attrs={'shape':'rect', 'fixedsize':'false'})
  File "/Users/blake/.local/share/virtualenvs/vocssd-E4rsV6CG/lib/python3.7/site-packages/mxnet/", line 382, in plot_network
    shape = shape_dict[key][1:]
KeyError: 'ssd1_box_nms0_output'

The plot_network function exists since gluoncv version 0.5.0 (development). Is there something I do wrong or should I file a bug report on GitHub? Or is there another way to visualise the network?


I tried the advice written in this post:

but it does not work. I did:

import mxnet as mx

# After running code from initial post
x = mx.sym.var('data')
sym = net(x)

This results in the error:

Traceback (most recent call last):
  File "<input>", line 4, in <module>
  File "/Users/blake/.local/share/virtualenvs/vocssd-E4rsV6CG/lib/python3.7/site-packages/mxnet/", line 273, in plot_network
    raise TypeError("symbol must be a Symbol")
TypeError: symbol must be a Symbol

Indeed there seems to be an issue with the shape information, but you can get the graph like this

import mxnet as mx
import gluoncv

net_name = 'ssd_512_resnet18_v1_coco'
net = gluoncv.model_zoo.get_model(net_name)
mx.viz.plot_network(net(mx.sym.var('data'))[0], node_attrs={"shape":"oval","fixedsize":"false"})

Super big thank you Thomas. It works!