For simpler models, a simple model summary is sufficient, but for more complex topologies, Keras provides a way to visualize the model. It is a layer on top of the graphviz
library.
Please make sure graphviz
is installed:
sudo apt-get install graphviz
Also, install pydot
, which is needed in the underlying implementation:
sudo pip install pydot
Let's take a look at an example where we create a simple model and call plot_model
on it.
The plot_model()
function in Keras creates a plot of the neural network. This function takes the following arguments:
model
: (required) The model that is to be plottedto_file
: (required) The name of the file to save the plotshow_shapes
: (optional, defaults toFalse
) Boolean to show the output shapes of each layershow_layer_names
: (optional, defaults toTrue
) Boolean to show the name for each layer
The following sections show how plot_model
can be used.