如何将 MXNet 图形可视化存储为文件中的图像?

How to store MXNet graph visualization as image in a file?

根据 this 页面,可以使用 mx.viz.plot_network(net) 可视化 MXNet 计算图。

但这只适用于 Jupyter notebook。没有 Jupyter notebook 怎么办?是否可以将可视化保存为文件中的图像?

mx.viz.plot_network returns 一个 graphviz.dot.Digraph 对象,它可以像任何其他 Digraph 对象一样呈现到文件中。

这是一个例子:

# Store the Digraph in a variable
graph = mx.viz.plot_network(net)

# Pick an image format from this list: http://www.graphviz.org/doc/info/output.html
graph.format = 'png'

# Choose a filename and render the image.
graph.render('graph')

以上代码将在当前目录中呈现 'graph.png' 中的图表。