我正在尝试将 TensorFlow 与我自己的 csv 数据一起使用,但看到无害的 "Enqueue operation canceled" 警告
I'm trying to use TensorFlow with my own csv data but seeing a harmless "Enqueue operation canceled" warning
我不确定出了什么问题。我检查了这个 link 并尝试修复错误,但它仍然存在。我正在尝试读取 csv 数据,然后预测列的结果。没有额外的库,只有准系统的 tensorflow 才能更好地理解。有什么想法吗?
编辑:
代码:
import tensorflow as tf
filename_queue = tf.train.string_input_producer(["keystrokes-strsep.csv"])
reader = tf.TextLineReader()
key, value = reader.read(filename_queue)
# Default values, in case of empty columns. Also specifies the type of the
# decoded result.
record_defaults = [[''], [''], [''], [''], ['']]
col1, col2, col3, col4, col5 = tf.decode_csv(value, record_defaults=record_defaults)
# print tf.shape(col1)
init = tf.initialize_all_variables()
features = tf.pack([col1, col2, col3, col4])
with tf.Session() as sess:
sess.run(init)
# Start populating the filename queue.
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
for i in range(114729):
# Retrieve a single instance:
example, label = sess.run([features, col5])
coord.request_stop()
coord.join(threads)
错误:
W tensorflow/core/common_runtime/executor.cc:1102] 0x7fe343d3fa40 Compute status: Cancelled: Enqueue operation was cancelled
[[Node: input_producer/input_producer_EnqueueMany = QueueEnqueueMany[Tcomponents=[DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](input_producer, input_producer/RandomShuffle)]]
I tensorflow/core/kernels/queue_base.cc:286] Skipping cancelled enqueue attempt
也许,使用 Numpy 从 csv 中读取值更简单。看这个简单的代码:
xy = np.loadtxt('train.txt', unpack=True, dtype='float32')
x_data = xy[0:-1]
y_data = xy[-1];
然后,您可以为您的操作提供 x_data 和 y_data。
在 http://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.loadtxt.html 查看更多
.
这实际上是运行期间正常的信息性消息,而不是错误。此消息表示在您 request_stop
时有记录等待被推送到队列中。特别是,您将查看您的 cvs 文件是否有超过 1200+queue capacity
条记录。
我不确定出了什么问题。我检查了这个 link 并尝试修复错误,但它仍然存在。我正在尝试读取 csv 数据,然后预测列的结果。没有额外的库,只有准系统的 tensorflow 才能更好地理解。有什么想法吗?
编辑:
代码:
import tensorflow as tf
filename_queue = tf.train.string_input_producer(["keystrokes-strsep.csv"])
reader = tf.TextLineReader()
key, value = reader.read(filename_queue)
# Default values, in case of empty columns. Also specifies the type of the
# decoded result.
record_defaults = [[''], [''], [''], [''], ['']]
col1, col2, col3, col4, col5 = tf.decode_csv(value, record_defaults=record_defaults)
# print tf.shape(col1)
init = tf.initialize_all_variables()
features = tf.pack([col1, col2, col3, col4])
with tf.Session() as sess:
sess.run(init)
# Start populating the filename queue.
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
for i in range(114729):
# Retrieve a single instance:
example, label = sess.run([features, col5])
coord.request_stop()
coord.join(threads)
错误:
W tensorflow/core/common_runtime/executor.cc:1102] 0x7fe343d3fa40 Compute status: Cancelled: Enqueue operation was cancelled
[[Node: input_producer/input_producer_EnqueueMany = QueueEnqueueMany[Tcomponents=[DT_STRING], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](input_producer, input_producer/RandomShuffle)]]
I tensorflow/core/kernels/queue_base.cc:286] Skipping cancelled enqueue attempt
也许,使用 Numpy 从 csv 中读取值更简单。看这个简单的代码:
xy = np.loadtxt('train.txt', unpack=True, dtype='float32')
x_data = xy[0:-1]
y_data = xy[-1];
然后,您可以为您的操作提供 x_data 和 y_data。
在 http://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.loadtxt.html 查看更多 .
这实际上是运行期间正常的信息性消息,而不是错误。此消息表示在您 request_stop
时有记录等待被推送到队列中。特别是,您将查看您的 cvs 文件是否有超过 1200+queue capacity
条记录。