提交 38089625 编写于 作者: C chengduozh

fix reader.md

上级 b97602f9
```eval_rst
.. _user_guide_reader:
```
# Python 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: 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): ...@@ -137,7 +133,7 @@ def reader_creator_random_image(width, height):
return reader return reader
def reader_creator_bool(t): def reader_creator_bool(t):
def reader: def reader():
while True: while True:
yield t yield t
return reader return reader
...@@ -145,7 +141,7 @@ def reader_creator_bool(t): ...@@ -145,7 +141,7 @@ def reader_creator_bool(t):
true_reader = reader_creator_bool(True) true_reader = reader_creator_bool(True)
false_reader = reader_creator_bool(False) 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. # 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. # 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}, ...) paddle.train(paddle.batch(reader, 128), {"true_image":0, "fake_image": 2, "true_label": 3, "false_label": 4}, ...)
......
```eval_rst
.. _user_guide_reader:
```
# Python Reader # Python Reader
在模型训练和预测阶段,PaddlePaddle程序需要读取训练或预测数据。为了帮助用户编写数据读取的代码,我们提供了如下接口: 在模型训练和预测阶段,PaddlePaddle程序需要读取训练或预测数据。为了帮助用户编写数据读取的代码,我们提供了如下接口:
...@@ -132,7 +128,7 @@ def reader_creator_random_image(width, height): ...@@ -132,7 +128,7 @@ def reader_creator_random_image(width, height):
return reader return reader
def reader_creator_bool(t): def reader_creator_bool(t):
def reader: def reader():
while True: while True:
yield t yield t
return reader return reader
...@@ -140,7 +136,7 @@ def reader_creator_bool(t): ...@@ -140,7 +136,7 @@ def reader_creator_bool(t):
true_reader = reader_creator_bool(True) true_reader = reader_creator_bool(True)
false_reader = reader_creator_bool(False) 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()为每个数据项生成两个项。 # 跳过1因为paddle.dataset.mnist.train()为每个数据项生成两个项。
# 并且这里我们暂时不考虑第二项。 # 并且这里我们暂时不考虑第二项。
paddle.train(paddle.batch(reader, 128), {"true_image":0, "fake_image": 2, "true_label": 3, "false_label": 4}, ...) paddle.train(paddle.batch(reader, 128), {"true_image":0, "fake_image": 2, "true_label": 3, "false_label": 4}, ...)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册