From c1ed3365440b808af34b39e9f5f69ae6ba3b552d Mon Sep 17 00:00:00 2001 From: Yanjun Peng Date: Wed, 1 Apr 2020 10:45:16 +0800 Subject: [PATCH] fix batch repeat usage order --- .../source_en/advanced_use/computer_vision_application.md | 6 +++--- tutorials/source_en/advanced_use/distributed_training.md | 6 +++--- .../advanced_use/computer_vision_application.md | 6 +++--- tutorials/source_zh_cn/advanced_use/distributed_training.md | 6 +++--- .../distributed_training/resnet50_distributed_training.py | 6 +++--- tutorials/tutorial_code/resnet/cifar_resnet50.py | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tutorials/source_en/advanced_use/computer_vision_application.md b/tutorials/source_en/advanced_use/computer_vision_application.md index 0f2359f314..1e1c6e4528 100644 --- a/tutorials/source_en/advanced_use/computer_vision_application.md +++ b/tutorials/source_en/advanced_use/computer_vision_application.md @@ -129,14 +129,14 @@ tar -zvxf cifar-10-binary.tar.gz Shuffle data randomly to disorder the data sequence and read data in batches for model training: ```python - # apply repeat operations - cifar_ds = cifar_ds.repeat(repeat_num) - # apply shuffle operations cifar_ds = cifar_ds.shuffle(buffer_size=10) # apply batch operations cifar_ds = cifar_ds.batch(batch_size=args_opt.batch_size, drop_remainder=True) + + # apply repeat operations + cifar_ds = cifar_ds.repeat(repeat_num) ``` diff --git a/tutorials/source_en/advanced_use/distributed_training.md b/tutorials/source_en/advanced_use/distributed_training.md index 7d859196e5..c34146b9b3 100644 --- a/tutorials/source_en/advanced_use/distributed_training.md +++ b/tutorials/source_en/advanced_use/distributed_training.md @@ -145,15 +145,15 @@ def create_dataset(repeat_num=1, batch_size=32, rank_id=0, rank_size=1): data_set = data_set.map(input_columns="label", operations=type_cast_op) data_set = data_set.map(input_columns="image", operations=c_trans) - # apply repeat operations - data_set = data_set.repeat(repeat_num) - # apply shuffle operations data_set = data_set.shuffle(buffer_size=10) # apply batch operations data_set = data_set.batch(batch_size=batch_size, drop_remainder=True) + # apply repeat operations + data_set = data_set.repeat(repeat_num) + return data_set ``` diff --git a/tutorials/source_zh_cn/advanced_use/computer_vision_application.md b/tutorials/source_zh_cn/advanced_use/computer_vision_application.md index e6ad3d3cc8..ca7c15ce61 100644 --- a/tutorials/source_zh_cn/advanced_use/computer_vision_application.md +++ b/tutorials/source_zh_cn/advanced_use/computer_vision_application.md @@ -131,14 +131,14 @@ tar -zvxf cifar-10-binary.tar.gz 最后通过数据混洗(shuffle)随机打乱数据的顺序,并按batch读取数据,进行模型训练: ```python - # apply repeat operations - cifar_ds = cifar_ds.repeat(repeat_num) - # apply shuffle operations cifar_ds = cifar_ds.shuffle(buffer_size=10) # apply batch operations cifar_ds = cifar_ds.batch(batch_size=args_opt.batch_size, drop_remainder=True) + + # apply repeat operations + cifar_ds = cifar_ds.repeat(repeat_num) ``` diff --git a/tutorials/source_zh_cn/advanced_use/distributed_training.md b/tutorials/source_zh_cn/advanced_use/distributed_training.md index b5b097b71d..8071832fe0 100644 --- a/tutorials/source_zh_cn/advanced_use/distributed_training.md +++ b/tutorials/source_zh_cn/advanced_use/distributed_training.md @@ -144,15 +144,15 @@ def create_dataset(repeat_num=1, batch_size=32, rank_id=0, rank_size=1): data_set = data_set.map(input_columns="label", operations=type_cast_op) data_set = data_set.map(input_columns="image", operations=c_trans) - # apply repeat operations - data_set = data_set.repeat(repeat_num) - # apply shuffle operations data_set = data_set.shuffle(buffer_size=10) # apply batch operations data_set = data_set.batch(batch_size=batch_size, drop_remainder=True) + # apply repeat operations + data_set = data_set.repeat(repeat_num) + return data_set ``` diff --git a/tutorials/tutorial_code/distributed_training/resnet50_distributed_training.py b/tutorials/tutorial_code/distributed_training/resnet50_distributed_training.py index 2db511100e..e363047ca8 100644 --- a/tutorials/tutorial_code/distributed_training/resnet50_distributed_training.py +++ b/tutorials/tutorial_code/distributed_training/resnet50_distributed_training.py @@ -69,15 +69,15 @@ def create_dataset(repeat_num=1, batch_size=32, rank_id=0, rank_size=1): data_set = data_set.map(input_columns="label", operations=type_cast_op) data_set = data_set.map(input_columns="image", operations=c_trans) - # apply repeat operations - data_set = data_set.repeat(repeat_num) - # apply shuffle operations data_set = data_set.shuffle(buffer_size=10) # apply batch operations data_set = data_set.batch(batch_size=batch_size, drop_remainder=True) + # apply repeat operations + data_set = data_set.repeat(repeat_num) + return data_set diff --git a/tutorials/tutorial_code/resnet/cifar_resnet50.py b/tutorials/tutorial_code/resnet/cifar_resnet50.py index da0620b7a4..eedf7e0c4d 100644 --- a/tutorials/tutorial_code/resnet/cifar_resnet50.py +++ b/tutorials/tutorial_code/resnet/cifar_resnet50.py @@ -91,15 +91,15 @@ def create_dataset(repeat_num=1, training=True): cifar_ds = cifar_ds.map(input_columns="label", operations=type_cast_op) cifar_ds = cifar_ds.map(input_columns="image", operations=c_trans) - # apply repeat operations - cifar_ds = cifar_ds.repeat(repeat_num) - # apply shuffle operations cifar_ds = cifar_ds.shuffle(buffer_size=10) # apply batch operations cifar_ds = cifar_ds.batch(batch_size=args_opt.batch_size, drop_remainder=True) + # apply repeat operations + cifar_ds = cifar_ds.repeat(repeat_num) + return cifar_ds if __name__ == '__main__': -- Gitee