When I run this line in my code,
from keras.utils import plot_model
I get the following:
"ImportError: cannot import name 'plot_model' from 'keras.utils' (/usr/local/lib/python3.7/dist-packages/keras/utils/__init__.py)"
When I went to bed last night it was working. This morning it throws an error. What happened and what should I do? Thank you. Any suggestion would be appreciated
The import was good but the function was throwing errors. In the recent version of keras, plot_model function has been moved to vis_utils (visualization utilities) under the utils module. So, you can get your plot_model function to work using either of these imports:
For understating a Keras Model, it always good to have visual representation of model layers. In this article we will see how to display Keras Model architecture and save to a file. tf.keras.utils provides plot_model function for plotting and saving Model architecture to the file. Create a sample Model with below code snippet.
model: A Keras model instance to_file: File name of the plot image. show_shapes: whether to display shape information. show_dtype: whether to display layer dtypes. show_layer_names: whether to display layer names.
The following are 14 code examples of keras.utils.vis_utils.plot_model () . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
Try to import in the below format
from keras.utils.vis_utils import plot_model
This week I've had the same problem, with this import it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With