【问题标题】:Error in tf.contrib.learn Quickstart, no attribute named load_csvtf.contrib.learn 快速入门中的错误,没有名为 load_csv 的属性
【发布时间】:2017-02-13 01:18:45
【问题描述】:

我在 OSX 上开始使用 tensorflow,并按照 pip 安装指南安装了最新版本:

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

快速概览:

操作系统:OS X El Capitan 版本 10.11.6 (15G31)

Python:Python 2.7.12_1 安装了brew install python

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

我可以使用以下方式运行 TensorFlow:

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

所以 TensorFlow 已安装并运行基本命令。

但是当我从这里运行 tf.contrib.learn Quickstart 的代码时: https://www.tensorflow.org/versions/r0.11/tutorials/tflearn/index.html

我遇到以下问题:

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'

我不知道出了什么问题,因为其他一切似乎都运行良好。有什么想法有什么问题吗?

【问题讨论】:

    标签: python macos python-2.7 tensorflow osx-elcapitan


    【解决方案1】:

    此功能已弃用:https://github.com/tensorflow/tensorflow/commit/2d4267507e312007a062a90df37997bca8019cfb

    而且教程似乎不是最新的。我相信您可以简单地将 load_csv 替换为 load_csv_with_header 以使其正常工作。

    【讨论】:

    • 谢谢。我用 load_csv_with_headers 替换了 load_csv,并为 feature_dtype=np.float32 添加了额外的参数。
    • @IsaacNoble 是features_dtype。来自base.pyload_csv_with_header(filename, target_dtype, features_dtype, target_column=-1)
    【解决方案2】:

    这里想要运行教程的人的快速修复。

    替换

    # 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)
    

    # 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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-13
      • 2014-05-30
      • 2023-03-15
      相关资源
      最近更新 更多