Paul Chandran
Paul Chandran

Reputation: 11

Tensorflow examples all fail due to AttributeError: 'module' object has no attribute 'load_csv'

I am running Tensor flow 0.11. This is the code which I just copied from TensorFlow tutorial to load CSV dataset.

Code

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)

Error

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

My question is i ran the same example in mac it was working fine but when i run it in ubuntu 14.04 LTS it shows this error. Can someone help to solve this issue.

Upvotes: 1

Views: 1325

Answers (1)

moonshang
moonshang

Reputation: 91

I have the same problem on mac when trying tensorflow's tutorial about Iris datasets. When I read into tensorflow codes about 'tf.contrib.learn.datasets.base', the function's name is actually 'load_csv_with_header', with three arguments. So try this:

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

Hope this could solve the problem.

Upvotes: 2

Related Questions