有没有办法在批次中修改我的图像的组成?目前,当我创建一个大小为4的批处理时,我的批次将如下所示:
Batch1:[Img0 Img1 Img2 Img3]
Batch2:[Img4 Img5 Img6 Img7]
我需要修改我的批次的组成,以便它只会移动一次到下一个图像.那应该是这样的:
Batch1:[Img0 Img1 Img2 Img3]
Batch2:[Img1 Img2 Img3 Img4]
Batch3:[Img2 Img3 Img4 Img5]
Batch4:[Img3 Img4 Img5 Img6]
Batch5:[Img4 Img5 Img6 Img7]
我在我的代码中使用了Tensorflow的Dataset API,如下所示:
def tfrecords_train_input(input_dir, examples, epochs, nsensors, past, future,
features, batch_size, threads, shuffle, record_type):
filenames = sorted(
[os.path.join(input_dir, f) for f in os.listdir(input_dir)])
num_records = 0
for fn in filenames:
for _ in tf.python_io.tf_record_iterator(fn):
num_records += 1
print("Number of files to use:", len(filenames), …
Run Code Online (Sandbox Code Playgroud)