2
$\begingroup$

I am using keras w/ PyCharm on windows 10. I am trying to print my tensorflow.keras.Model using

from keras.utils.vis_utils import plot_model
...
res_net_model = tf.keras.Model(inputs=inputs,outputs=outputs)
...
plot_model(res_net_model)      #, to_file='cnn_resnet_model.bmp') #, show_shapes=True, show_layer_names=True)    

I am for some reason getting

  File "C:\Users\Zack's 2016 Tower\.conda\envs\tensorz\lib\site-packages\keras\utils\vis_utils.py", line 240, in plot_model
    expand_nested, dpi)
  File "C:\Users\Zack's 2016 Tower\.conda\envs\tensorz\lib\site-packages\keras\utils\vis_utils.py", line 79, in model_to_dot
    _check_pydot()
  File "C:\Users\Zack's 2016 Tower\.conda\envs\tensorz\lib\site-packages\keras\utils\vis_utils.py", line 28, in _check_pydot
    pydot.Dot.create(pydot.Dot())
  File "C:\Users\Zack's 2016 Tower\.conda\envs\tensorz\lib\site-packages\pydotplus\graphviz.py", line 2032, in create
    status, stderr_output))
pydotplus.graphviz.InvocationException: Program terminated with status: 1. stderr follows: Format: "ps" not recognized. Use one of:


Process finished with exit code 1

I have confirmed that graphviz & pydotplus has been installed by conda. I've also tried to installing graphviz as an executable that's within my path.

I've looked through similar postings such as this and this with no luck: nothing matches my error. It doesn't even tell me what formats I should use (although this may have the answer). It shouldn't matter because atm I'm not asking it to generate an image. I have no idea where it is getting 'ps' from.

$\endgroup$
1
  • $\begingroup$ ps could refer to PostScript, a page description language to create PDFs, vector graphics and such. Do you have it installed? Do you run your code in notebook or via command line? $\endgroup$ – Tinu May 20 '20 at 8:40
2
$\begingroup$

I had exactly the same problem today and stumbled upon your question. As it had no replies, I dug further and eventually found something that helped me. For you it may be too late but anyone else having this problem, maybe it helps if I document my finding.

For the background: my setup is Python 3.7 under Windows 10.

The keras function plot_model uses pydot which itself relies on GraphViz. Moreover, the error message Format: "ps" not recognized. Use one of: you see is caused by dot, one of the tools that belongs to GraphViz, which is called from inside pydot. After playing around with the dot tool, it eventually told me the following:

There is no layout engine support for "dot" Perhaps "dot -c" needs to be run (with installer's privileges) to register the plugins?

So, I fired up a new console with administrator priviliges and ran dot -c. This enabled dot to use its layout engines and this made the error disappear. After this, plot_model suddenly worked for me.

Hope it helps anyone.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.