0
我想加載一個大的CSV文件到一個TensorFlow管道,其中每行代表一個扁平的256 * 256圖像。我想概括TensorFlow CSV文件中讀取的例子,但我有麻煩推廣的decode_csv功能器。---我所有的列:廣義Tensorflow CSV加載
def file_len(fname):
with open(fname) as f:
for i, l in enumerate(f):
pass
return i + 1
# setup text reader
file_length = file_len(filename)
filename_queue = tf.train.string_input_producer([filename])
reader = tf.TextLineReader(skip_header_lines=1)
_, csv_row = reader.read(filename_queue)
# setup CSV decoding
record_defaults = [[0] for i in range(256*256)]
col = tf.decode_csv(csv_row, record_defaults=record_defaults)
features = tf.pack([col[i] for i in range(256*256))
print("loading, " + str(file_length) + " line(s)\n")
with tf.Session() as sess:
tf.initialize_all_variables().run()
# start populating filename queue
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
for i in range(file_length):
# retrieve a single instance
example, label = sess.run([features, col5])
print(example, label)
coord.request_stop()
coord.join(threads)
print("\ndone loading")
但是我得到的錯誤
TypeError: Expected list for 'values' argument to 'Pack' Op, not <generator object <genexpr> at 0x12447e2d0>
如何推廣col1,... colN部分?