Keras: plot_model has a AssertionError

Created on 24 Mar 2019  路  5Comments  路  Source: keras-team/keras

When I run the following code
plot_model(model,show_shapes=True,to_file="test.png")

It appears following error:

"dot" with args ['-Tps', 'C:\Users\Public\Documents\Wondershare\CreatorTemp\tmpknhr3o1n'] returned code: 1

stdout, stderr:
b''
b"'D:\Program' \xb2\xbb\xca\xc7\xc4\xda\xb2\xbf\xbb\xf2\xcd\xe2\xb2\xbf\xc3\xfc\xc1\xee\xa3\xac\xd2\xb2\xb2\xbb\xca\xc7\xbf\xc9\xd4\xcb\xd0\xd0\xb5\xc4\xb3\xcc\xd0\xf2\r\n\xbb\xf2\xc5\xfa\xb4\xa6\xc0\xed\xce\xc4\xbc\xfe\xa1\xa3\r\n"


AssertionError Traceback (most recent call last)
in
4 model = Model(inputs=[encoder_inputs, decoder_inputs], outputs=decoder_outputs)
5 # plot the model
----> 6 plot_model(model,show_shapes=True,to_file="encoder_decoder.png")

D:\Program Files\Anaconda3\envs\tensorflow\lib\site-packages\keras\utils\vis_utils.py in plot_model(model, to_file, show_shapes, show_layer_names, rankdir)
130 'LR' creates a horizontal plot.
131 """
--> 132 dot = model_to_dot(model, show_shapes, show_layer_names, rankdir)
133 _, extension = os.path.splitext(to_file)
134 if not extension:

D:\Program Files\Anaconda3\envs\tensorflow\lib\site-packages\keras\utils\vis_utils.py in model_to_dot(model, show_shapes, show_layer_names, rankdir)
53 from ..models import Sequential
54
---> 55 _check_pydot()
56 dot = pydot.Dot()
57 dot.set('rankdir', rankdir)

D:\Program Files\Anaconda3\envs\tensorflow\lib\site-packages\keras\utils\vis_utils.py in _check_pydot()
24 # Attempt to create an image of a blank graph
25 # to check the pydot/graphviz installation.
---> 26 pydot.Dot.create(pydot.Dot())
27 except OSError:
28 raise OSError(

D:\Program Files\Anaconda3\envs\tensorflow\lib\site-packages\pydot.py in create(self, prog, format, encoding)
1943 print(message)
1944
-> 1945 assert process.returncode == 0, process.returncode
1946
1947 return stdout_data

AssertionError: 1

I can import successfully with
import pydot import graphviz

But when I run
pydot.Dot.create(pydot.Dot())
It happens the same error: AssertionError

tensorflow awaiting response support

Most helpful comment

@ymodak I solved it. I uninstall pydot and pip install pydot-ng. Then change the code in '...\keras\utils\vis_utils.py'

import pydot_ng as pydot
instead of
import pydot

All 5 comments

In order to expedite the trouble-shooting process, please provide a code snippet to reproduce the issue reported here. Thanks!

@ymodak I solved it. I uninstall pydot and pip install pydot-ng. Then change the code in '...\keras\utils\vis_utils.py'

import pydot_ng as pydot
instead of
import pydot

It works for pydotplus too. Thanks!

I solved the issue commenting line 117 program += extension in pydot.py

it works fine

Was this page helpful?
0 / 5 - 0 ratings