1. 程式人生 > >使用tensorflow 輸入佇列讀取 檔案一行 時報錯

使用tensorflow 輸入佇列讀取 檔案一行 時報錯

input_queue = tf.train.string_input_producer([filenames_file], shuffle=False)
line_reader = tf.TextLineReader()
_, line = line_reader.read(input_queue)
split_line = tf.string_split([line]).values
center_image_path = tf.string_join([self.data_path, '/',split_line[0]])
top_image_path = tf.string_join([self.data_path,'/', split_line[1]])
bottom_image_path = tf.string_join([self.data_path,'/', split_line[2]])
horizonal_image_path0 = tf.string_join([self.data_path,'/', split_line[3]])
horizonal_image_path1 = tf.string_join([self.data_path,'/', split_line[4]]

2018-10-08 20:26:26.408728: W tensorflow/core/framework/op_kernel.cc:1318] OP_REQUIRES failed at strided_slice_op.cc:105 : Invalid argument: slice index 0 of dimension 0 out of bounds. 2018-10-08 20:26:26.408813: W tensorflow/core/framework/op_kernel.cc:1318] OP_REQUIRES failed at strided_slice_op.cc:105 : Invalid argument: slice index 3 of dimension 0 out of bounds. 2018-10-08 20:26:26.408830: W tensorflow/core/framework/op_kernel.cc:1318] OP_REQUIRES failed at strided_slice_op.cc:105 : Invalid argument: slice index 4 of dimension 0 out of bounds. 2018-10-08 20:26:26.408843: W tensorflow/core/framework/op_kernel.cc:1318] OP_REQUIRES failed at strided_slice_op.cc:105 : Invalid argument: slice index 2 of dimension 0 out of bounds. 2018-10-08 20:26:26.408857: W tensorflow/core/framework/op_kernel.cc:1318] OP_REQUIRES failed at strided_slice_op.cc:105 : Invalid argument: slice index 1 of dimension 0 out of bounds.

這種情況是因為讀取txt 檔案一行時進行切片,有可能是你一中切片後的資料不夠導致的。這時候應該檢查佇列讀取的檔案是否生成有誤。