Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name 'model_to_dot'

I want to visualize Keras model using Google Colab environment. I found this link. However, I get an error if I copy-paste the code from this link to the Colab notebook:

from IPython.display import SVG
from keras.utils import model_to_dot

SVG(model_to_dot(model).create(prog='dot', format='svg'))

Error:

ImportError                               Traceback (most recent call last)
<ipython-input-9-819c3bda4aa6> in <module>()
      1 from IPython.display import SVG
----> 2 from keras.utils import model_to_dot
      3 
      4 SVG(model_to_dot(model).create(prog='dot', format='svg'))

ImportError: cannot import name 'model_to_dot'
like image 849
ingrid Avatar asked Jan 22 '19 11:01

ingrid


2 Answers

model_to_dot can be imported if you change line 2 with:

from keras.utils.vis_utils import model_to_dot
like image 192
Moldovan Daniel Avatar answered Oct 31 '22 17:10

Moldovan Daniel


model_to_dot can be imported if you change line 2 with:

from tensorflow.keras.utils import model_to_dot
like image 1
Bhavesh Avatar answered Oct 31 '22 18:10

Bhavesh