解决问题:OSError: pydot failed to call GraphViz.Please install GraphViz (https://www.graphviz.org/)

1.前言:在运行Keras框架上的可视化代码时,遇到如下问题:

OSError: pydot failed to call GraphViz.Please install GraphViz (https://www.graphviz.org/) and ensure that its executables are in the $PATH. 

2.解决方法:

(1)安装相关模块:

pip install pydot-ng 
pip install graphviz 
pip install pydot==1.2.3  #这个很关键

(2)下载文件:raphviz-2.38.msi

  链接:https://pan.baidu.com/s/19IwMBJC33LApbi_lU0YUVg   提取码:4r22 

(3)下载完成后直接安装到自己的指定目录,然后将安装目录添加到电脑的系统环境变量中。

(4)完成。

3.举例:

from keras.models import Sequential
from keras.layers import Dense, Activation
from keras.utils import plot_model

model = Sequential()
model.add(Dense(32, activation='relu', input_dim=100))
model.add(Dense(1, activation='sigmoid'))
model.compile(optimizer='rmsprop',
              loss='binary_crossentropy',
              metrics=['accuracy'])

# Generate dummy data
import numpy as np
data = np.random.random((1000, 100))
labels = np.random.randint(2, size=(1000, 1))
plot_model(model, to_file='model.png',show_shapes=True)

参考文献:

1.https://blog.csdn.net/u011311291/article/details/80298563

2.https://github.com/XifengGuo/CapsNet-Keras/issues/7

  • 11
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 12
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值