Skip to main content
 首页 » 编程设计

python之我正在尝试将 TensorFlow 与我自己的 csv 数据一起使用,但看到无害的 "Enqueue operation canceled"警告

2024年10月24日35unruledboy

我不确定哪里出了问题。我检查了这个 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 

请您参考如下方法:

这实际上是运行期间正常的信息性消息,而不是错误。此消息表示当您执行 request_stop 时,有记录等待被推送到队列中。特别是,您将查看您的 cvs 文件是否超过 1200+queue capacity 记录。