Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't import plot_model from keras.utils?

Tags:

python

keras

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

like image 680
arsinniusyahoocom Avatar asked May 26 '21 11:05

arsinniusyahoocom


People also ask

Is it possible to import the plot_model function in keras?

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:

How to display keras model architecture to a file?

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.

What is the use of show_shapes in keras?

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.

How many keras code examples are there?

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.


1 Answers

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.

like image 99
Pat Avatar answered Sep 28 '22 12:09

Pat