【发布时间】:2020-01-26 15:36:49
【问题描述】:
我已经安装了 pydotplus 和 graphviz(我运行 Windows 10 和 Python 3.6)。
但是,当我尝试绘制我的 Keras 模型时,我遇到了一个异常,我被要求安装 pytdot 和 graphviz。
keras.utils.plot_model(model, 'my_first_model.png')
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pydot.py in create(self, prog, format, encoding)
1914 arguments=arguments,
-> 1915 working_dir=tmp_dir,
1916 )
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pydot.py in call_graphviz(program, arguments, working_dir, **kwargs)
135 stdout=subprocess.PIPE,
--> 136 **kwargs
137 )
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors)
708 errread, errwrite,
--> 709 restore_signals, start_new_session)
710 except:
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
996 os.fspath(cwd) if cwd is not None else None,
--> 997 startupinfo)
998 finally:
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
FileNotFoundError Traceback (most recent call last)
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tensorflow\python\keras\utils\vis_utils.py in _check_pydot()
44 # to check the pydot/graphviz installation.
---> 45 pydot.Dot.create(pydot.Dot())
46 except Exception:
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\pydot.py in create(self, prog, format, encoding)
1921 prog=prog)
-> 1922 raise OSError(*args)
1923 else:
FileNotFoundError: [WinError 2] "dot" not found in path.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-58-f0e169c88003> in <module>()
----> 1 keras.utils.plot_model(model, 'my_first_model.png')
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tensorflow\python\keras\utils\vis_utils.py in plot_model(model, to_file, show_shapes, show_layer_names, rankdir)
151 This enables in-line display of the model plots in notebooks.
152 """
--> 153 dot = model_to_dot(model, show_shapes, show_layer_names, rankdir)
154 _, extension = os.path.splitext(to_file)
155 if not extension:
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tensorflow\python\keras\utils\vis_utils.py in model_to_dot(model, show_shapes, show_layer_names, rankdir)
70 from tensorflow.python.util import nest
71
---> 72 _check_pydot()
73 dot = pydot.Dot()
74 dot.set('rankdir', rankdir)
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tensorflow\python\keras\utils\vis_utils.py in _check_pydot()
47 # pydot raises a generic Exception here,
48 # so no specific class can be caught.
---> 49 raise ImportError('Failed to import pydot. You must install pydot'
50 ' and graphviz for `pydotprint` to work.')
51
ImportError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.
不清楚为什么我会收到此错误消息。既然我已经安装了包,还有什么要做的呢?
graphviz 已下载
【问题讨论】:
-
我查过了。但我已经下载了 graphviz 并将其添加到我的系统路径中。查看我更新的帖子。
-
这里有一些有用的建议。对于考虑提供帮助的读者来说,这对你来说同样重要。 (1) 你可能问的问题太多了。两天内发布八篇帖子意味着您无需等待一件事的答案,然后再跳到下一件事。这将进一步向我表明您没有进行必要的研究。 (2) 您正在添加关于感谢帮助的闲聊材料,尽管许多编辑已从您之前的帖子中删除了此内容。技术写作在这里是一种期望。可根据要求提供元参考。
标签: python tensorflow plot keras