Error in tf.contrib.learn Quickstart, no attribute named load_csv

核能气质少年 提交于 2020-01-05 04:21:29

问题


I am getting started in tensorflow on OSX and installed the lasted version following the guidelines for a pip installation using:

echo $TF_BINARY_URL
https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.11.0rc0-py2-none-any.whl

Quick overview:

OS: OS X El Capitan version 10.11.6 (15G31)

Python: Python 2.7.12_1 installed with brew install python

TensorFlow: 0.11.0rc0 from import tensorflow as tf; print(tf.__version__)

I can run TensorFlow using:

python
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
>>> Hello, TensorFlow!

So TensorFlow is installed and running the basic commands.

But when I run the code for tf.contrib.learn Quickstart from here: https://www.tensorflow.org/versions/r0.11/tutorials/tflearn/index.html

I get the following issue:

Traceback (most recent call last):
  File "tf_learn_quickstart.py", line 13, in <module>
    training_set = tf.contrib.learn.datasets.base.load_csv(filename=IRIS_TRAINING,
AttributeError: 'module' object has no attribute 'load_csv'

I can't figure out what went wrong as everything else seems to be working fine. Any ideas what is wrong?


回答1:


This function has been deprecated: https://github.com/tensorflow/tensorflow/commit/2d4267507e312007a062a90df37997bca8019cfb

And the tutorial seems not up to date. I believe you can simply replace load_csv with load_csv_with_header to get it work.




回答2:


The quick fix for people here wanting to run the tutorial.

Replace

# Load datasets.
training_set = tf.contrib.learn.datasets.base.load_csv(filename=IRIS_TRAINING,
                                                       target_dtype=np.int)
test_set = tf.contrib.learn.datasets.base.load_csv(filename=IRIS_TEST,
                                                   target_dtype=np.int)

with

# Load datasets.
training_set = tf.contrib.learn.datasets.base.load_csv_with_header(filename=IRIS_TRAINING,
                                                                  target_dtype=np.int,
                                                                  features_dtype=np.float32,
                                                                  target_column=-1)
test_set     = tf.contrib.learn.datasets.base.load_csv_with_header(filename=IRIS_TEST,
                                                                  target_dtype=np.int,
                                                                  features_dtype=np.float32,
                                                                  target_column=-1)


来源:https://stackoverflow.com/questions/39859670/error-in-tf-contrib-learn-quickstart-no-attribute-named-load-csv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!