【填坑记】使用keras绘制(plot_model)网络结构图总是出错的解决办法

本人使用的开发环境

python3.6.8+tensorflow1.9+keras2.2.4

前提:已经正确安装pydot和graphviz的python软件包,并且安装windows的graphviz安装包,并且配置好了环境变量

错误:pydot不能够正确调用graphviz,请确保已经安装了graphviz并配置了环境变量

网络上其它的解决方案:

(1)确保安装顺序正确:graphviz->grapphviz软件本身并配置环境变量->pydot

         尝试失败

(2)改用pydot_ng,于是安装 pip install pydot_ng

    尝试失败

(3)环境变量要这样配置

添加GRAPHVIZ_DOT=“D:\Program Files (x86)\Graphviz2.38\bin”(这是我的graphviz的安装路径)

给系统的PATH环境变量添加值,“D:\Program Files (x86)\Graphviz2.38\bin”

给用户的PATH环境变量添加值,“D:\Program Files (x86)\Graphviz2.38\bin”

     尝试失败

我的解决办法:

问题其实是pydot的锅。pydot已经停止开发了,python3.5、python3.6、python3.7已经不能使用了,由于我的环境是python3.6.8,自然会出错,于是我安装了pydot的新版本pydotplus

即:

pip install pydotplus

然后在自己安装的keras文件夹里面找到keras里面的  utils\vis_utils.py  这个文件,把代码里面的的pydot的都替换成pydotplus(直接使用批量替换即可,手动替换也行,这个文件代码量很少)

  尝试成功!

下面来看一下这个pydototplus到底是个啥?

PyDotPlus is an improved version of the old pydot project that provides a Python Interface to Graphviz’s Dot language.

(pyplotplus是pyplot的升级版本)

http://pydotplus.readthedocs.org/

Differences with pydot(与pyplot的不同点):

  • Compatible with PyParsing 2.0+.
  • Python 2.7 - Python 3 compatible.
  • Well documented.
  • CI Tested.

Installation

pip install pydotplus

Documentation

User guide and API Reference can be found in:

http://pydotplus.readthedocs.org/

Requirements

  • pyparsing: pydot requires the pyparsing module in order to be able to load DOT files.
  • GraphViz: is needed in order to render the graphs into any of the plethora of output formats supported.
  • 依赖于graphviz和pyparsing这两个包。
  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值