AttributeError: module 'tensorflow.contrib.learn' 没有属性 'TensorFlowDNNClassifier'



这是我试图执行 -

import tensorflow.contrib.learn as skflow
from sklearn import datasets, metrics
iris = datasets.load_iris()
classifier = skflow.TensorFlowDNNClassifier(hidden_units=[10, 20, 10], n_classes=3)
classifier.fit(iris.data, iris.target)
score = metrics.accuracy_score(iris.target, classifier.predict(iris.data))
print("Accuracy: %f" % score)

它给出以下错误 -

追溯(最近的最新电话):

文件" c: users admin test3.py",第5行,

classifier = skflow.tensorflowdnnclassifier(hidden_units = [10,20,10],n_classes = 3)attributeError:module'tensorflow.contrib.contrib.learn' 没有属性" TensorFlowDnnClassifier"

[用退出代码1完成69.3s]

[shell_cmd:python -u" c: users admin admin test3.py"]

似乎在Tensorflow项目中有一个主要的重构,并且所有skflow代码都已在主张量储存库下移动。

尝试将TensorFlowDNNClassifier替换为DNNClassifier。新课可以在这里找到。您的校正代码看起来像

import tensorflow.contrib.learn as skflow
from sklearn import datasets, metrics
iris = datasets.load_iris()
# made a change in the next line
classifier = skflow.DNNClassifier(hidden_units=[10, 20, 10], n_classes=3)
classifier.fit(iris.data, iris.target)
score = metrics.accuracy_score(iris.target, classifier.predict(iris.data))
print("Accuracy: %f" % score)
import tensorflow.contrib.learn.python
from tensorflow.contrib.learn.python import learn as learn

相关内容

  • 没有找到相关文章

最新更新