4

I'm trying to draw the keras model with the plotmodel.

Setup:

I installed graphviz binaries with:

choco install graphviz

added path to the bin folder, and then I did:

pip install pydotplus
pip install graphviz

Code:

Getting this error when I try to execute:

from keras.models import Sequential
from keras.layers import Dense
from keras.utils.vis_utils import plot_model
model = Sequential()
model.add(Dense(2, input_dim=1, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
plot_model(model, to_file='model_plot.png', show_shapes=True, show_layer_names=True)

Error:

ImportError: Failed to import pydot. You must install pydot and graphviz for pydotprint to work.

Can someone suggest some alternative to draw the keras model? I need to implement this for a CNN.

Stephen Rauch
  • 1,831
  • 11
  • 23
  • 34
Srihari
  • 797
  • 4
  • 12
  • 27

1 Answers1

1

In addition to what you have already done, in my notebook I added two lines:

import os
os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz2.38/bin/'

(Source)

Stephen Rauch
  • 1,831
  • 11
  • 23
  • 34
Supamee
  • 111
  • 3