How to Solve Keras calls plot_model error

1. Error information

When building the neural network model, you can call plot in keras_ The model module draws a schematic diagram of the model to facilitate the adjustment of the model structure:

from tensorflow.keras.models import Model
from tensorflow.keras.utils import plot_model
model = Model(dense_inputs+sparse_inputs, output_layer)
plot_model(model, "fm_model.png", show_shapes=True)

As a result, the following error messages appear:

(‘Failed to import pydot. You must pip install pydot and install graphviz (ht

tps:// ), ‘, ‘for pydotprint to work.’)

Understand the error message: the installation is complete without pydot and graphviz packages

2. Solutions

2.1 installation of graphviz package

pip install graphviz

2.2 download and install graphviz Exe file and install

In Windows Environment

Download address:

2.3 configuring environment variables for graphviz

2.4 installing pydot package

pip install pydot-ng

2.5 restart development tools

Restart the IDE or other development tools (Jupiter notebook) with immediate effect.

3. Summary

1. Installing pydot and graphviz packages directly according to the error message does not work

2. You need to go to the website to download the corresponding EXE file or zip file. After installation, specify the environment variables

3. Don’t forget to restart your ide or other development tools

Read More: