mxnet
mxnet copied to clipboard
Is there a bug when I use visualization.py in mxnet?
I want to visualize my net structure using mx.viz.plot_network. My net structure include such code:
slice = mx.symbol.SliceChannel(data=conv, num_outputs=2, name="slice_1")
act = mx.symbol.maximum(slice[0], slice[1])
when do the visualize, it will repot such error:
Traceback (most recent call last):
File "visual.py", line 7, in <module>
a = mx.viz.plot_network(net, shape = {"data": (1, 3, 256, 256)}, node_attrs= {"shape": 'rect', "fixedsize": 'false'} )
File "/home/xxx/.virtualenvs/cv/local/lib/python2.7/site-packages/mxnet-0.7.0-py2.7.egg/mxnet/visualization.py", line 140, in plot_network
shape = shape_dict[key][1:]
KeyError: u'slice_1_output'
I check the visualize.py,When the layer named 'slice_1' pass in and it will joint a output name automatically:
if draw_shape:
if input_node["op"] != "null":
key = input_name + "_output" # auto create a name 'slice_1_output'
shape = shape_dict[key][1:] # shape_dict only has the name "slice_1_output1"
# and "slice_1_output0", so the inconsistent of name convention cause the error!
How to solve this problem, thanks!
I guess this bug occurs when it meet the operator that has multi outputs like SliceChannel, and change the code slightly to let the visualize process run normally:
key = input_name + "_output"
if "param" in input_node:
params = input_node["param"]
if "num_outputs" in params:
key += str(int(params["num_outputs"]) - 1)
params["num_outputs"] = int(params["num_outputs"]) - 1
shape = shape_dict[key][1:]
Now it works after unify the name convention
This issue is closed due to lack of activity in the last 90 days. Feel free to reopen if this is still an active issue. Thanks!