tf.contrib.learn Quickstart: Fix float64 Warning
<p>I'm getting myself started with TensorFlow by working through the posted tutorials.</p>

<p>I have the Linux CPU python2.7 version 0.10.0 running on Fedora 23 (twenty three).</p>

<p>I am trying the tf.contrib.learn Quickstart tutorial as per the following code.</p>

<blockquote>
  <p><a href="https://www.tensorflow.org/versions/r0.10/tutorials/tflearn/index.html#tf-contrib-learn-quickstart" rel="nofollow">https://www.tensorflow.org/versions/r0.10/tutorials/tflearn/index.html#tf-contrib-learn-quickstart</a></p>
</blockquote>

<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_data/iris_training.csv"
IRIS_TEST = "IRIS_data/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 Code Executes, but gives float64 warnings. As Such:</p>

<pre><code>$ python confErr.py
WARNING:tensorflow:load_csv (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed after 2016-09-15.
Instructions for updating:
Please use load_csv_{with|without}_header instead.
WARNING:tensorflow:load_csv (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed after 2016-09-15.
Instructions for updating:
Please use load_csv_{with|without}_header instead.
WARNING:tensorflow:Using default config.
WARNING:tensorflow:float64 is not supported by many models, consider casting to float32.
WARNING:tensorflow:Setting feature info to TensorSignature(dtype=tf.float64, shape=TensorShape([Dimension(None), Dimension(4)]), is_sparse=False)
WARNING:tensorflow:Setting targets info to TensorSignature(dtype=tf.int64, shape=TensorShape([Dimension(None)]), is_sparse=False)
WARNING:tensorflow:float64 is not supported by many models, consider casting to float32.
WARNING:tensorflow:Given features: Tensor("input:0", shape=(?, 4), dtype=float64), required signatures: TensorSignature(dtype=tf.float64, shape=TensorShape([Dimension(None), Dimension(4)]), is_sparse=False).
WARNING:tensorflow:Given targets: Tensor("output:0", shape=(?,), dtype=int64), required signatures: TensorSignature(dtype=tf.int64, shape=TensorShape([Dimension(None)]), is_sparse=False).
Accuracy: 0.966667
WARNING:tensorflow:float64 is not supported by many models, consider casting to float32.
Predictions: [1 1]
</code></pre>

<p>Note: replace 'load_csv()' with 'load_csv_with_header()' produces the correct Prediction. but float64 warnings remain.</p>

<p>I have tried explicitly listing dtype (np.int32 ; np.float32; tf.int32; tf.float32) for training_set, test_set and new_samples.</p>

<p>I also tried 'casting' feature_columns as:</p>

<pre><code>feature_columns = tf.cast(feature_columns, tf.float32)
</code></pre>

<p>The problems with float64 are known development issue, but I'm wondering if there is some workaround?</p>

<p>I received this answer from the development team via Git-hub.</p>

<blockquote>
  <p>Hi @qweelar, the float64 warning is due to a bug with the load_csv_with_header function that was fixed in commit b6813bd. This fix isn't in TensorFlow release 0.10, but should be in the next release.</p>
  
  <p>In the meantime, for the purposes of the tf.contrib.learn quickstart, you can safely ignore the float64 warning.</p>
  
  <p>(Side note: In terms of the other deprecation warning, I will be updating the tutorial code to use load_csv_with_header, and will update this issue when that's in place.)</p>
</blockquote>

python python-2.7 tensorflow