Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
TensorFlow中的洗牌与训练_Tensorflow_Shuffle_Training Data - Fatal编程技术网

TensorFlow中的洗牌与训练

TensorFlow中的洗牌与训练,tensorflow,shuffle,training-data,Tensorflow,Shuffle,Training Data,我正在使用此代码解码CSV文件: def read_csv(batch_size, file_name, record_defaults): filename_queue = tf.train.string_input_producer([file_name]) reader = tf.TextLineReader(skip_header_lines=1) key, value = reader.read(filename_queue) decoded = tf.deco

我正在使用此代码解码CSV文件:

def read_csv(batch_size, file_name, record_defaults):
   filename_queue = tf.train.string_input_producer([file_name])
   reader = tf.TextLineReader(skip_header_lines=1)
   key, value = reader.read(filename_queue)
   decoded = tf.decode_csv(value, record_defaults=record_defaults)

   return tf.train.batch(decoded, batch_size=batch_size, capacity=batch_size*50, allow_smaller_final_batch=True)
考虑我的CSV文件如下(40行;数字1、2、3和4的10倍):

两个问题: (1) 当我使用tf.train.batch时,批大小为10,步骤数=4,在培训期间从队列中获取的批为:

step 1: [1,1,1,1,1,1,1,1,1,1]
step 2: [3,3,3,3,3,3,3,3,3,3]
step 3: [1,1,1,1,1,1,1,1,1,1]
step 4: [3,3,3,3,3,3,3,3,3,3]
。。。我不明白为什么。我想它会在每一步10个批次中正确采样1、2、3和4

(2) 当我使用tf.train.shuffle\u batch而不是tf.train.batch时,洗牌输出类似于:

step 1: [1,1,1,1,2,2,1,1,2,1]
step 2: [4,3,4,3,2,1,4,3,3,2]
step 3: [4,1,1,2,1,1,1,2,2,2]
step 4: [3,3,3,1,3,4,2,4,4,4]
为什么有些数字在这里表示,例如13次(数字1)或8次(数字4),而不是10次?出于这个原因,我想如果我只使用4个步骤进行训练,我的纪元是不完整的,因为有些数字没有被采用

step 1: [1,1,1,1,2,2,1,1,2,1]
step 2: [4,3,4,3,2,1,4,3,3,2]
step 3: [4,1,1,2,1,1,1,2,2,2]
step 4: [3,3,3,1,3,4,2,4,4,4]