TransWikia.com

Creating graphs of CNN models: cannot use plot_model from keras.utils.vis_utils

Data Science Asked by danglingPointer on September 8, 2020

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:UsersZack's 2016 Tower.condaenvstensorzlibsite-packageskerasutilsvis_utils.py", line 240, in plot_model
    expand_nested, dpi)
  File "C:UsersZack's 2016 Tower.condaenvstensorzlibsite-packageskerasutilsvis_utils.py", line 79, in model_to_dot
    _check_pydot()
  File "C:UsersZack's 2016 Tower.condaenvstensorzlibsite-packageskerasutilsvis_utils.py", line 28, in _check_pydot
    pydot.Dot.create(pydot.Dot())
  File "C:UsersZack's 2016 Tower.condaenvstensorzlibsite-packagespydotplusgraphviz.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.

One Answer

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.

Answered by Florian on September 8, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP