TensorFlow > csvファイルを読もうとして失敗 > TypeError: Expected string, got 3 of type 'int' instead.

```txt:動作環境
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 14.04 LTS desktop amd64
TensorFlow v0.11
cuDNN v5.1 for Linux
CUDA v8.0
Python 2.7.6
```

http://qiita.com/7of9/items/e5d59cdd8d4dd865e7a8
の続き。

```csvTest.csv
$ cat csvTest.csv 
0,1,2,3,4,5
10,20,30,40,50
```

上記のcsvファイルをx_data, y_dataに読んで処理しようとしている。

参考 http://qiita.com/yanosen_jp/items/9af64be89dc9963cb67b

```linreg_readcsv.py
import tensorflow as tf
import numpy as np
import random

#x_data = np.float32(np.random.rand(100)) # Random input
#y_data = np.sin(2*np.pi*x_data) + 0.3 * np.random.rand()

filename_queue = tf.train.string_input_producer(["csvTest.csv"])
reader = tf.TextLineReader()
x_data, y_data = reader.read(filename_queue)

# Construct a linear model.
W3 = tf.Variable(random.random())
W2 = tf.Variable(random.random())
W1 = tf.Variable(random.random())
W0 = tf.Variable(random.random())
# y3 = W2*x_data*x_data + W1*x_data + W0
#y4 = W3*x_data*x_data*x_data+W2*x_data*x_data + W1*x_data + W0
y4 = W3*(x_data**3)+W2*(x_data**2) + W1*x_data + W0


# Minimize the squared errors.
loss = tf.reduce_mean(tf.square(y4 - y_data))
optimizer = tf.train.GradientDescentOptimizer(0.5)
train = optimizer.minimize(loss)

# For initializing the variables.
init = tf.initialize_all_variables()

# Launch the graph
sess = tf.Session()
sess.run(init)

# Fit the plane.
for step in xrange(0, 5000):
    sess.run(train)
print step, sess.run(W3), sess.run(W2), sess.run(W1), sess.run(W0)
```

```txt:結果
$ python linreg_readcsv.py 
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcurand.so locally
Traceback (most recent call last):
  File "linreg_readcsv.py", line 19, in <module>
    y4 = W3*(x_data**3)+W2*(x_data**2) + W1*x_data + W0
  File "/home/yasokada/tensorflow-GPU/local/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.py", line 750, in binary_op_wrapper
    y = ops.convert_to_tensor(y, dtype=x.dtype.base_dtype, name="y")
  File "/home/yasokada/tensorflow-GPU/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 657, in convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "/home/yasokada/tensorflow-GPU/local/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 180, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
  File "/home/yasokada/tensorflow-GPU/local/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 163, in constant
    tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape))
  File "/home/yasokada/tensorflow-GPU/local/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 353, in make_tensor_proto
    _AssertCompatible(values, dtype)
  File "/home/yasokada/tensorflow-GPU/local/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 290, in _AssertCompatible
    (dtype.name, repr(mismatch), type(mismatch).__name__))
TypeError: Expected string, got 3 of type 'int' instead.
```

TypeErrorとなった。

### x_data, y_data

上記で読込んだx_data, y_dataをprintしてみた。

```
...
print 'x_data', x_data
print 'y_data', y_data
...
```

```txt:結果
x_data Tensor("ReaderRead:0", shape=(), dtype=string)
y_data Tensor("ReaderRead:1", shape=(), dtype=string)
```

dtypeがstringのTensorになっている。


以下に読込み用コード例が掲示されている。decode_csv()を使うようだ。
https://www.tensorflow.org/versions/r0.11/how_tos/reading_data/index.html#file-formats