davisking / dlib

A toolkit for making real world machine learning and data analysis applications in C++
http://dlib.net
Boost Software License 1.0
13.23k stars 3.34k forks source link

Feature: net_to_dot visitor #2521

Closed arrufat closed 2 years ago

arrufat commented 2 years ago

Some time ago, I noticed that Keras has a nice functionality to plot models.

So, I thought it would be really cool to have something similar in dlib, as it allows for easier debugging of the networks, aside from being cool to visualize.

Last night, I implemented a net_to_dot visitor which outputs a graph in the dot language so that we can easily convert into almost any kind of graphical format. You just need to call it exactly like the net_to_xml visitor. Maybe net_to_graph would be a better name?

I guess my question is: would you be interested in adding this kind of functionality to dlib? If so, I will prepare a PR :)

Here are some examples of what this visitor can generate.

From the resnet.h file: resnet18.pdf From the semantic segmentation example: unet.pdf A classical DenseNet: densenet121.pdf Another architecture to test more layers: vovnet39.pdf

arrufat commented 2 years ago

I've updated the style of the nodes, so that it's easier to debug a network:

Enjoy!

densenet121.pdf vovnet39.pdf resnet18.pdf unet.pdf yolor-p6.pdf

EDIT: thanks to this visitor, I found a couple of bugs in my YOLO model implementation.

arrufat commented 2 years ago

Closing as of #2528