15

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

S.EB
  • 1,966
  • 4
  • 29
  • 54

4 Answers4

39

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.

Dr. Snoopy
  • 55,122
  • 7
  • 121
  • 140
13

Tensorflow 2:

from tensorflow.keras.utils import plot_model
Mendi Barel
  • 3,350
  • 1
  • 23
  • 24
2

Use

from keras.utils import plot_model

instead

Sreejith Menon
  • 1,057
  • 1
  • 18
  • 27
Tim K
  • 21
  • 2
1

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

SAch
  • 69
  • 8