答案 0 :(得分:0)
如果要从每一列中输入一个字符串
# NOTE: count is computed ahead of time by looping over all the tfrecord entries
with tf.device('/cpu:0'):
sample_size = int(count * 0.05)
random_indexes = set(np.random.randint(low=0, high=count, size=sample_size))
stat_graph = tf.Graph()
with tf.Session(graph=stat_graph) as sess:
val_sum = np.zeros(shape=(180, 2050))
for file in files:
print("Reading from file: %s" % file)
for record in tf.python_io.tf_record_iterator(file):
features = tf.parse_single_example(
record,
features={
"val": tf.FixedLenFeature((180, 2050), tf.float32),
})
if index in random_indexes:
val_sum += features["val"].eval(session=sess)
index += 1
val_mean = val_sum / sample_size
答案 1 :(得分:0)
我假设您要在一个变量中使用第1列的所有值,而在另一个变量中使用第2列的所有值?
column1 = [row[0] for row in data] # makes a list of all values of column 1
column2 = [row[1] for row in data] # does the same for column 2
P.S .:如果您要进行大量CSV工作,我建议您使用pandas。它将使您的生活更轻松:)