reading data in tensorflow - TypeError("%s that don't all match." % prefix)
<p>I am trying to load the following data file (with 225805 rows) in tensor flow. The data file looks like this:</p>

<pre><code>1,1,0.05,-1.05
1,1,0.1,-1.1
1,1,0.15,-1.15
1,1,0.2,-1.2
1,1,0.25,-1.25
1,1,0.3,-1.3
1,1,0.35,-1.35
</code></pre>

<p>the code that reads the data is</p>

<pre><code>import tensorflow as tf

# read in data
filename_queue = tf.train.string_input_producer(["~/input.data"])
reader = tf.TextLineReader()
key, value = reader.read(filename_queue)

record_defaults = [tf.constant([], dtype=tf.int32),    # Column 1
                   tf.constant([], dtype=tf.int32),    # Column 2
                   tf.constant([], dtype=tf.float32),  # Column 3
                   tf.constant([], dtype=tf.float32)]  # Column 4

col1, col2, col3, col4 = tf.decode_csv(value, record_defaults=record_defaults)
features = tf.pack([col1, col2, col3])

with tf.Session() as sess:
  coord = tf.train.Coordinator()
  threads = tf.train.start_queue_runners(coord=coord)

  for i in range(225805):
    example, label = sess.run([features, col4])

  coord.request_stop()
  coord.join(threads)
</code></pre>

<p>and this is the error I am getting</p>

<pre><code>Traceback (most recent call last):
  File "dummy.py", line 16, in &lt;module&gt;
    features = tf.pack([col1, col2, col3])
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 487, in pack
    return gen_array_ops._pack(values, axis=axis, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 1462, in _pack
    result = _op_def_lib.apply_op("Pack", values=values, axis=axis, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 437, in apply_op
    raise TypeError("%s that don't all match." % prefix)
TypeError: Tensors in list passed to 'values' of 'Pack' Op have types [int32, int32, float32] that don't all match.
</code></pre>

<p>The <a href="https://www.tensorflow.org/versions/r0.10/api_docs/python/array_ops.html#pack" rel="nofollow"><code>tf.pack()</code></a> operator requires that all of the tensors passed to it have the same element type. In your program, the first two tensors have type <code>tf.int32</code>, while the third tensor has type <code>tf.float32</code>. The simplest solution is to cast the first two tensors to have type <code>tf.float32</code>, using the <a href="https://www.tensorflow.org/versions/r0.10/api_docs/python/array_ops.html#to_float" rel="nofollow"><code>tf.to_float()</code></a> operator:</p>

<pre><code>features = tf.pack([tf.to_float(col1), tf.to_float(col2), col3])
</code></pre>

python tensorflow