Skip to content

Commit

Permalink
Increase Prefetch in Example (#832)
Browse files Browse the repository at this point in the history
* support channel_first

* YAPF Corrections

* yapf

* change prefetech number

* prefetch
  • Loading branch information
zsdonghao committed Sep 9, 2018
1 parent d42ef66 commit 2014577
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions examples/basic_tutorials/tutorial_cifar10_datasetapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ def _map_fn_test(img, target):
ds = ds.map(_map_fn_train, num_parallel_calls=multiprocessing.cpu_count())
ds = ds.repeat(n_epoch)
ds = ds.shuffle(shuffle_buffer_size)
ds = ds.prefetch(buffer_size=2)
ds = ds.prefetch(buffer_size=4096)
ds = ds.batch(batch_size)
value = ds.make_one_shot_iterator().get_next()

ds = tf.data.Dataset().from_generator(generator_test, output_types=(tf.float32,
tf.int32)) # , output_shapes=((24, 24, 3), (1)))
ds = ds.shuffle(shuffle_buffer_size)
ds = ds.map(_map_fn_test, num_parallel_calls=multiprocessing.cpu_count())
ds = ds.repeat(n_epoch)
ds = ds.shuffle(shuffle_buffer_size)
ds = ds.prefetch(buffer_size=2)
ds = ds.prefetch(buffer_size=4096)
ds = ds.batch(batch_size)
value_test = ds.make_one_shot_iterator().get_next()

Expand Down
4 changes: 2 additions & 2 deletions examples/data_process/tutorial_tf_dataset_voc.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ def _map_fn(filename, annotation):
image, annotation = tf.py_func(_data_aug_fn, [image, annotation], [tf.float32, tf.string])
return image, annotation


ds = tf.data.Dataset().from_generator(generator, output_types=(tf.string, tf.string))
ds = ds.shuffle(shuffle_buffer_size)
ds = ds.map(_map_fn, num_parallel_calls=multiprocessing.cpu_count())
ds = ds.repeat(n_epoch)
ds = ds.shuffle(shuffle_buffer_size)
ds = ds.prefetch(buffer_size=2048)
ds = ds.batch(batch_size)
value = ds.make_one_shot_iterator().get_next()

Expand Down

0 comments on commit 2014577

Please sign in to comment.