程序源码(节选):
exampleBatch1, labelBatch1 = batch_input(dataPath, num_epochs=100)
with tf.Session() as sess:
init_op = tf.group(tf.global_variables_initializer(), tf.local_variables_initializer())
sess.run(init_op)
#exampleBatch1, labelBatch1 = batch_input(dataPath, num_epochs=100)
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(sess=sess, coord=coord)
try:while not coord.should_stop():
example_batch, label_batch = sess.run([exampleBatch1, labelBatch1])
print("example_batch is:")
print(example_batch)
except tf.errors.OutOfRangeError:
print('Done training -- epoch limit reached')
finally:
coord.request_stop()
coord.join(threads)
运行时报以下错误:
Traceback (most recent call last):
File "better_nonlinear_one_input_batch1.py", line 64, in <module>
coord.join(threads)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/coordinator.py", line 389, in join
six.reraise(*self._exc_info_to_raise)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/queue_runner_impl.py", line 238, in _run
enqueue_callable()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1231, in _single_operation_run
target_list_as_strings, status, None)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/errors_impl.py", line 473, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Field 7 in record 0 is not a valid int32: 12/19/2017 10:40:43
[[Node: DecodeCSV = DecodeCSV[OUT_TYPE=[DT_STRING, DT_STRING, DT_STRING, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_INT32, DT_STRING, DT_INT32, DT_STRING, DT_STRING], field_delim=",", na_value="", use_quote_delim=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](ReaderReadV2:1, DecodeCSV/record_defaults_0, DecodeCSV/record_defaults_1, DecodeCSV/record_defaults_0, DecodeCSV/record_defaults_3, DecodeCSV/record_defaults_3, DecodeCSV/record_defaults_3, DecodeCSV/record_defaults_3, DecodeCSV/record_defaults_7, DecodeCSV/record_defaults_0, DecodeCSV/record_defaults_7, DecodeCSV/record_defaults_1, DecodeCSV/record_defaults_0)]]
经过仔细检查,csv数据中有1行,其中的一列数据出现错误(第7列):
本应该是距离的数值(整型),此处变成了日期值,类型错误,修正后程序可正常运行。