1

我正在学习逻辑回归概念的概念。当我在 python 中实现它时,它向我显示了下面提到的一些错误。我是python的初学者。有人可以帮助纠正这个错误吗?

() 中的 RuntimeError Traceback(最近一次调用最后一次)

64 theano.printing.pydotprint(predict,
65                            outfile="pics/logreg_pydotprint_predic.png",
66                            var_with_name_simple=True)
67 # before compilation
68 theano.printing.pydotprint_variables(prediction,

C:\Anaconda\lib\site-packages\theano\printing.pyc in pydotprint(fct, outfile, compact, format, with_ids, high_contrast, cond_highlight, colorCodes, max_label_size, scan_graphs, var_with_name_simple, print_output_file, assert_nb_all_strings)

565 
566     if not pydot_imported:
567         raise RuntimeError("Failed to import pydot. You must install pydot"
568                             " for `pydotprint` to work.")
569         return

RuntimeError: 无法导入 pydot。您必须安装 pydotpydotprint才能工作。

4

3 回答 3

2

我遇到了同样的错误,我在 Python 3 中执行了以下序列以使其工作:

source activate anaconda
pip install pydot
pip install pydotplus
pip install pydot-ng

然后根据您的操作系统类型从此处下载并安装 Graphviz:http: //www.graphviz.org/Download..php

如果您在 Anaconda 上运行 Python,请从终端打开 Spyder,而不是从 Anaconda。转到终端并输入:

spyder

然后:

import theano
import theano.tensor as T
.
.
.
import pydot
import graphviz
import pydot_ng as pydot

开发您的模型并:

theano.printing.pydotprint(prediction, outfile="/Volumes/Python/prediction.png", var_with_name_simple=True)

你会有这样的图片: 在此处输入图像描述

于 2016-10-04T00:15:59.297 回答
1

这主要取决于您放置 pydot 文件的位置。如果您直接从 Python Shell 运行它,那么您应该将它们安装在模块文件夹中,该文件夹最常见的是主 python 文件夹中的“Lib”文件夹。

于 2013-05-22T04:51:24.647 回答
1

我也有同样的问题。我建议你在 Github Theano 问题论坛上发布这个:

https://github.com/Theano/Theano/issues?direction=desc&sort=updated&state=open

在我看来,因为 pydotprint() 函数的这个实例实际上是 Theano 库中打印模块的一部分,所以这不应该是一个问题(但确实如此),因此应该引起开发人员的注意为了修复它。

如果不是这种情况,请纠正我。

于 2014-02-02T16:46:32.297 回答