Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named 'keras.utils.visualize_util'

Hi when I am trying to run a code in keras it is showing me the following error:

from keras.utils.visualize_util import plot
ImportError: No module named 'keras.utils.visualize_util'

How can I solve this? thanks

like image 979
S.EB Avatar asked Apr 20 '17 06:04

S.EB


4 Answers

Use

from keras.utils import plot_model

instead

like image 124
Tim K Avatar answered Nov 13 '22 02:11

Tim K


Tensorflow 2:

from tensorflow.keras.utils import plot_model
like image 35
Mendi Barel Avatar answered Nov 13 '22 03:11

Mendi Barel


You will have to either fix the code manually, or downgrade Keras.

By looking at the commit history of that module, you can see that it was renamed on February 28, 2017 from visualize_util to vis_utils. The plot function was also renamed to plot_model.

You will have to update the code to reflect these changes, or use a proper Keras version where the code you are using was developed or tested.

like image 38
Dr. Snoopy Avatar answered Nov 13 '22 02:11

Dr. Snoopy


Instead of using this:

from tensorflow.keras.utils.np_utils import to_categorical

Use this instead:

from tensorflow.python.keras.utils.np_utils import to_categorical

like image 1
SAch Avatar answered Nov 13 '22 03:11

SAch