Why tensor flow could not load csv
<p>I just installed tensor flow using pip and I try to run the following tutorial:</p>

<p><a href="https://www.tensorflow.org/versions/r0.11/tutorials/tflearn/index.html" rel="nofollow">https://www.tensorflow.org/versions/r0.11/tutorials/tflearn/index.html</a></p>

<pre><code># Data sets
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)
</code></pre>

<p>But I have error:</p>

<pre><code>    training_set = tf.contrib.learn.datasets.base.load_csv(filename=IRIS_TRAINING,
AttributeError: 'module' object has no attribute 'load_csv'
</code></pre>

<p>I read some answer saying that I need to use pandas dataframe? But shouldn't everything just works as in the tutorial? That is so strange! I should not be the only one facing this issue right?</p>

<p>Here's the whole code as in the tutorial:</p>

<pre><code>from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import tensorflow as tf
import numpy as np

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

# Specify that all features have real-value data
feature_columns = [tf.contrib.layers.real_valued_column("", dimension=4)]

# Build 3 layer DNN with 10, 20, 10 units respectively.
classifier = tf.contrib.learn.DNNClassifier(feature_columns=feature_columns,
                                            hidden_units=[10, 20, 10],
                                            n_classes=3,
                                            model_dir="/tmp/iris_model")

# Fit model.
classifier.fit(x=training_set.data,
               y=training_set.target,
               steps=2000)

# Evaluate accuracy.
accuracy_score = classifier.evaluate(x=test_set.data,
                                     y=test_set.target)["accuracy"]
print('Accuracy: {0:f}'.format(accuracy_score))

# Classify two new flower samples.
new_samples = np.array(
    [[6.4, 3.2, 4.5, 1.5], [5.8, 3.1, 5.0, 1.7]], dtype=float)
y = classifier.predict(new_samples)
print('Predictions: {}'.format(str(y)))
</code></pre>

<p>The function <code>tf.contrib.learn.datasets.base.load_csv()</code> was removed in TensorFlow release 0.11. Depending on whether the file has a header or not (and the Iris dataset does have a header), the replacement functions are:</p>

<ul>
<li><a href="https://github.com/tensorflow/tensorflow/blob/fcab4308002412e38c1a6d5c6145119f04540d45/tensorflow/contrib/learn/python/learn/datasets/base.py#L38" rel="nofollow"><code>tf.contrib.learn.datasets.base.load_csv_with_headers()</code></a></li>
<li><a href="https://github.com/tensorflow/tensorflow/blob/fcab4308002412e38c1a6d5c6145119f04540d45/tensorflow/contrib/learn/python/learn/datasets/base.py#L57" rel="nofollow"><code>tf.contrib.learn.datasets.base.load_csv_without_headers()</code></a></li>
</ul>

python tensorflow