diff --git a/doc/fluid/user_guides/howto/prepare_data/reader.md b/doc/fluid/user_guides/howto/prepare_data/reader.md index fab10bdd4473d3f1cb0cbc9dcddd60ff863e3412..bfba87966ea57c4c0d5a166077185b55727b024d 100644 --- a/doc/fluid/user_guides/howto/prepare_data/reader.md +++ b/doc/fluid/user_guides/howto/prepare_data/reader.md @@ -1,7 +1,3 @@ -```eval_rst -.. _user_guide_reader: -``` - # Python Reader During the training and testing phases, PaddlePaddle programs need to read data. To help the users write code that performs reading input data, we define the following: @@ -137,7 +133,7 @@ def reader_creator_random_image(width, height): return reader def reader_creator_bool(t): - def reader: + def reader(): while True: yield t return reader @@ -145,7 +141,7 @@ def reader_creator_bool(t): true_reader = reader_creator_bool(True) false_reader = reader_creator_bool(False) -reader = paddle.reader.compose(paddle.dataset.mnist.train(), data_reader_creator_random_image(20, 20), true_reader, false_reader) +reader = paddle.reader.compose(paddle.dataset.mnist.train(), reader_creator_random_image(20, 20), true_reader, false_reader) # Skipped 1 because paddle.dataset.mnist.train() produces two items per data entry. # And we don't care about the second item at this time. paddle.train(paddle.batch(reader, 128), {"true_image":0, "fake_image": 2, "true_label": 3, "false_label": 4}, ...) diff --git a/doc/fluid/user_guides/howto/prepare_data/reader_cn.md b/doc/fluid/user_guides/howto/prepare_data/reader_cn.md index f4e3178a85d4f7c3944c0d3c204a35ad3d1bb010..30e1693958f4aefada507f9f4dc997cc684848fb 100644 --- a/doc/fluid/user_guides/howto/prepare_data/reader_cn.md +++ b/doc/fluid/user_guides/howto/prepare_data/reader_cn.md @@ -1,7 +1,3 @@ -```eval_rst -.. _user_guide_reader: -``` - # Python Reader 在模型训练和预测阶段,PaddlePaddle程序需要读取训练或预测数据。为了帮助用户编写数据读取的代码,我们提供了如下接口: @@ -132,7 +128,7 @@ def reader_creator_random_image(width, height): return reader def reader_creator_bool(t): - def reader: + def reader(): while True: yield t return reader @@ -140,7 +136,7 @@ def reader_creator_bool(t): true_reader = reader_creator_bool(True) false_reader = reader_creator_bool(False) -reader = paddle.reader.compose(paddle.dataset.mnist.train(), data_reader_creator_random_image(20, 20), true_reader, false_reader) +reader = paddle.reader.compose(paddle.dataset.mnist.train(), reader_creator_random_image(20, 20), true_reader, false_reader) # 跳过1因为paddle.dataset.mnist.train()为每个数据项生成两个项。 # 并且这里我们暂时不考虑第二项。 paddle.train(paddle.batch(reader, 128), {"true_image":0, "fake_image": 2, "true_label": 3, "false_label": 4}, ...)