在Tensorflow分类示例中出现tf.train.get.global_step错误

我正在按照Siraj Raval的YouTube视频教程,构建一个用于鸢尾花数据集的简单分类器。视频发布于2016年5月,因此我确定Tensorflow的一些部分已经更新。我遇到了一个错误,提示“请切换到tf.train.get.global_step”。我使用的是较旧版本的Tensorflow库,并且我尝试通过研究feature_columns来解决这个问题。我以为这样可以解决问题,但错误仍然存在。任何帮助都将不胜感激,并且关于如何成为Tensorflow的熟练用户的任何建议都将非常欢迎。

这是我的代码

import tensorflow.contrib.learn as skflowfrom sklearn import datasets, metricsiris = datasets.load_iris()feature_columns = skflow.infer_real_valued_columns_from_input(iris.data)classifier = skflow.LinearClassifier(feature_columns=feature_columns, n_classes=3)classifier.fit(iris.data, iris.target)score = metrics.accuracy_score(iris.target, classifier.predict(iris.data))print("Accuracy: %f" % score)

这是错误信息:

WARNING:tensorflow:float64 is not supported by many models, consider casting to float32.WARNING:tensorflow:Using temporary folder as model directory: C:\Users\isaia\AppData\Local\Temp\tmp8be6vyhqWARNING:tensorflow:From C:/Users/isaia/PycharmProjects/untitled5/ml.py:10: calling BaseEstimator.fit (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.Instructions for updating:Estimator is decoupled from Scikit Learn interface by moving intoseparate class SKCompat. Arguments x, y and batch_size are onlyavailable in the SKCompat class, Estimator will only accept input_fn.Example conversion:  est = Estimator(...) -> est = SKCompat(Estimator(...))WARNING:tensorflow:From C:/Users/isaia/PycharmProjects/untitled5/ml.py:10: calling BaseEstimator.fit (from tensorflow.contrib.learn.python.learn.estimators.estimator) with y is deprecated and will be removed after 2016-12-01.Instructions for updating:Estimator is decoupled from Scikit Learn interface by moving intoseparate class SKCompat. Arguments x, y and batch_size are onlyavailable in the SKCompat class, Estimator will only accept input_fn.Example conversion:  est = Estimator(...) -> est = SKCompat(Estimator(...))WARNING:tensorflow:float64 is not supported by many models, consider casting to float32.WARNING:tensorflow:From C:\Users\isaia\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\linear.py:173: get_global_step (from tensorflow.contrib.framework.python.ops.variables) is deprecated and will be removed in a future version.Instructions for updating:Please switch to tf.train.get_global_step

提前感谢您的帮助


回答:

这个估计器基本上已经废弃,可能会在Tensorflow的下一个版本中被移除(您会收到多个相关的警告),您应该使用tf.estimator.LinearClassifier。它的API略有不同,但基本思想是一样的。以下是完整代码:

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注