Plot a Keras model
# S3 method for keras.engine.training.Model plot( x, show_shapes = FALSE, show_dtype = FALSE, show_layer_names = TRUE, ..., rankdir = "TB", expand_nested = FALSE, dpi = 96, layer_range = NULL, show_layer_activations = FALSE, to_file = NULL )
A Keras model instance
whether to display shape information.
whether to display layer dtypes.
whether to display layer names.
passed on to
keras$utils$plot_model(). Used for forward and
a string specifying the format of the plot:
'TB' creates a
'LR' creates a horizontal plot. (argument passed to PyDot)
Whether to expand nested models into clusters.
Dots per inch. Increase this value if the image text appears excessively pixelated.
list containing two character strings, which is the
starting layer name and ending layer name (both inclusive) indicating the
range of layers for which the plot will be generated. It also accepts regex
patterns instead of exact name. In such case, start predicate will be the
first element it matches to
layer_range and the end predicate will be
the last element it matches to
layer_range. By default
considers all layers of model. Note that you must pass range such that the
resultant subgraph must be complete.
Display layer activations (only for layers that
File name of the plot image. If
NULL (the default), the
model is drawn on the default graphics device. Otherwise, a file is saved.
Nothing, called for it's side effects.
plot_model is called before the model is
built, unless a
input_shape = argument was supplied to
This function requires pydot and graphviz.
pydot is by default installed by
install_keras(), but if you installed
tensorflow by other means, you can install pydot directly with :
reticulate::py_install("pydot", pip = TRUE)
In a conda environment, you can install graphviz with:
reticulate::conda_install(packages = "graphviz") # Restart the R session after install.
Otherwise you can install graphviz from here: https://graphviz.gitlab.io/download/