kears可视化模块keras.utils.visualize_util 的安装配置与错误解决办法

Traceback (most recent call last): File "D:\ProgramData\Anaconda3\lib\site-packages\keras\utils\vis_utils.py", line 27, in _check_pydot pydot.Dot.create(pydot.Dot()) File "D:\ProgramData\Anaconda3\lib\site-packages\pydot_ng\__init__.py", line 1890, in create 'GraphViz\'s executables not found')pydot_ng.InvocationException: GraphViz's executables not foundDuring handling of the above exception, another exception occurred:Traceback (most recent call last): File "E:/mypython_Linking/CNN/myCNN.py", line 57, in plot_model(model, to_file='model1.png', show_shapes=True)

  File "D:\ProgramData\Anaconda3\lib\site-packages\keras\utils\vis_utils.py", line 135, in plot_model

    dot = model_to_dot(model, show_shapes, show_layer_names, rankdir)

  File "D:\ProgramData\Anaconda3\lib\site-packages\keras\utils\vis_utils.py", line 56, in model_to_dot

    _check_pydot()

  File "D:\ProgramData\Anaconda3\lib\site-packages\keras\utils\vis_utils.py", line 31, in _check_pydot

    raise ImportError('Failed to import pydot. You must install pydot'

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

以上为Pycharm中出现的错误信息提示


解决方法:

1. cmd进入windows     2. pip install pydot       3. pip install graphviz   

kears可视化模块keras.utils.visualize_util 的安装配置与错误解决办法_第1张图片

4. 还需要安装graphviz软件:https://graphviz.gitlab.io/_pages/Download/Download_windows.html,然后下载graphviz-2.38.msi

kears可视化模块keras.utils.visualize_util 的安装配置与错误解决办法_第2张图片
下载graphviz-2.38.msi

5.记住自己的安装地址,配置环境变量:

kears可视化模块keras.utils.visualize_util 的安装配置与错误解决办法_第3张图片
记住自己的安装目标,配置环境变量

6.检查graphviz是否安装成功,cmd进入windows命令行,输入命令:dot -version

kears可视化模块keras.utils.visualize_util 的安装配置与错误解决办法_第4张图片
cmd进入windows命令行,输入命令:dot -version

7.最后一步,在自己需要允许的python模块中加入:

from keras.utils.vis_utils import plot_model  #方便打印模型图片

import os

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

-------------------------------------------------------------------------------------

打印下图的语句:

plot_model(model,to_file='model1.png',show_shapes=True)

kears可视化模块keras.utils.visualize_util 的安装配置与错误解决办法_第5张图片
正确运行得到的图片

你可能感兴趣的:(kears可视化模块keras.utils.visualize_util 的安装配置与错误解决办法)