gpt4 book ai didi

python-2.7 - 由于 AttributeError : 'module' object has no attribute 'load_csv' ,Tensorflow 示例全部失败

转载 作者:行者123 更新时间:2023-11-30 09:00:45 25 4
gpt4 key购买 nike

我正在运行 tensorflow 0.11。这是我刚刚从 TensorFlow 教程中复制的用于加载 CSV 数据集的代码。

代码

import tensorflow as tf
import numpy as np


IRIS_TRAINING = "iris_training.csv"
IRIS_TEST = "iris_test.csv"

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

错误

AttributeError: 'module' object has no attribute 'load_csv'

我的问题是我在 mac 中运行了相同的示例,它工作正常,但是当我在 ubuntu 14.04 LTS 中运行它时,它显示了此错误。有人可以帮忙解决这个问题吗?

最佳答案

当我尝试使用tensorflow关于Iris数据集的教程时,我在Mac上遇到了同样的问题。当我读到有关“tf.contrib.learn.datasets.base”的 tensorflow 代码时,该函数的名称实际上是“load_csv_with_header”,带有三个参数。所以试试这个:

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

希望这能解决问题。

关于python-2.7 - 由于 AttributeError : 'module' object has no attribute 'load_csv' ,Tensorflow 示例全部失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39853281/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com