は、ここで私はcsvファイルのTensorFlowのdtypeを変更するにはどうすればよいですか?
import tensorflow as tf
import numpy as np
import input_data
filename_queue = tf.train.string_input_producer(["cs-training.csv"])
reader = tf.TextLineReader()
key, value = reader.read(filename_queue)
record_defaults = [[1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1]]
col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11 = tf.decode_csv(
value, record_defaults=record_defaults)
features = tf.concat(0, [col2, col3, col4, col5, col6, col7, col8, col9, col10, col11])
with tf.Session() as sess:
# Start populating the filename queue.
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
for i in range(1200):
# Retrieve a single instance:
print i
example, label = sess.run([features, col1])
try:
print example, label
except:
pass
coord.request_stop()
coord.join(threads)
このコードは以下のエラーを返すランしようとしていたコードです。
---------------------------------------------------------------------------
InvalidArgumentError Traceback (most recent call last)
<ipython-input-23-e42fe2609a15> in <module>()
7 # Retrieve a single instance:
8 print i
----> 9 example, label = sess.run([features, col1])
10 try:
11 print example, label
/root/anaconda/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in run(self, fetches, feed_dict)
343
344 # Run request and get response.
--> 345 results = self._do_run(target_list, unique_fetch_targets, feed_dict_string)
346
347 # User may have fetched the same tensor multiple times, but we
/root/anaconda/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in _do_run(self, target_list, fetch_list, feed_dict)
417 # pylint: disable=protected-access
418 raise errors._make_specific_exception(node_def, op, e.error_message,
--> 419 e.code)
420 # pylint: enable=protected-access
421 raise e_type, e_value, e_traceback
InvalidArgumentError: Field 1 in record 0 is not a valid int32: 0.766126609
私はこの問題には関係しないと考えている情報がたくさんあります。明らかに問題は、私がプログラムに与えている多くのデータがdtype int32ではないということです。これは主に浮動小数点数です。私はtf.decode_csv
とtf.concat
に明示的にdtype=float
引数を設定するのと同様に、dtypeを変更するいくつかの試みを試みました。どちらもうまくいかなかった。それは無効な議論です。このコードが実際にデータを予測するかどうかはわかりません。私はそれがcol1が1か0になるかどうかを予測したいと思っていますし、コード内に実際にその予測をすることを示唆する何も表示されません。たぶん私は別のスレッドのためにその質問を保存します。どんな助けでも大歓迎です!