Keras and Gephi : Visualize your Deep Learning Graph

If you work on Machine Learning / Deep Learning with Keras, you can export the model in a dot file. And guess what ? Gephi can read dot files ! 😀

To do that use this code (adapt it for your usecase)

from keras.applications import *
from keras.utils import plot_model
# [..]
# model = ...
# Get your own model here
# [..]
model = NASNetMobile() #Example with NASNetMobile
plot_model(model,show_shapes=False, to_file='')

Then it will generate a file that you can open directly into Gephi !