The network architecture of Convolutional Neural Networks (CNN) can be heavily layered and complex. Viewing the network visually is a great way to get a sense of its architecture. Since the network is a graph, it is easy to visualize this using GraphViz.
Caffe requires its Net to be in the Google ProtoBuf format. It also provides a
draw_net.py script that can be used to output the graph to all the formats supported by GraphViz.
- From the Caffe root directory, you can export a
.prototxtmodel file as a graph to a PNG image file:
$ python/draw_net.py foo.prototxt foo.png
Possible output formats include PNG, PDF, DOT and others supported by GraphViz.
- By default, the net layers are drawn from left-to-right. I prefer to visualize a CNN in top-to-bottom fashion:
$ python/draw_net.py --rankdir TB foo.prototxt foo.png
- I prefer to interact with the graph visualization, which is a bit difficult with an image file. So, I prefer to export to DOT format file and play with it using XDot:
$ python/draw_net.py foo.prototxt foo.dot $ xdot foo.dot
Tried with: Ubuntu 14.04