Skip to content

Commit 261d5f0

Browse files
authored
Merge pull request #11409 from panyx0718/doc
Add API docs.
2 parents f4dce56 + c1843fd commit 261d5f0

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

paddle/fluid/operators/get_places_op.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class GetPlacesOpProtoMaker : public framework::OpProtoAndCheckerMaker {
8585
.InEnum({"CUDA", "CPU", "AUTO"})
8686
.SetDefault("AUTO");
8787
AddComment(R"DOC(
88-
Returns a list of places based on flags. The list will be used for parallel
88+
Returns a list of places based on arguments. The list will be used for parallel
8989
execution.
9090
)DOC");
9191
}

python/paddle/fluid/layers/control_flow.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,34 @@ def __exit__(self, exc_type, exc_val, exc_tb):
12091209

12101210

12111211
class IfElse(object):
1212+
"""
1213+
if-else control flow.
1214+
1215+
Args:
1216+
cond (Variable): condition used to compare.
1217+
name (str, default None): The name of this layer.
1218+
1219+
Examples:
1220+
.. code-block:: python
1221+
1222+
limit = fluid.layers.fill_constant_batch_size_like(
1223+
input=label, dtype='int64', shape=[1], value=5.0)
1224+
cond = fluid.layers.less_than(x=label, y=limit)
1225+
ie = fluid.layers.IfElse(cond)
1226+
with ie.true_block():
1227+
true_image = ie.input(image)
1228+
hidden = fluid.layers.fc(input=true_image, size=100, act='tanh')
1229+
prob = fluid.layers.fc(input=hidden, size=10, act='softmax')
1230+
ie.output(prob)
1231+
1232+
with ie.false_block():
1233+
false_image = ie.input(image)
1234+
hidden = fluid.layers.fc(
1235+
input=false_image, size=200, act='tanh')
1236+
prob = fluid.layers.fc(input=hidden, size=10, act='softmax')
1237+
ie.output(prob)
1238+
prob = ie()
1239+
"""
12121240
OUT_IF_ELSE_BLOCKS = 0
12131241
IN_IF_ELSE_TRUE_BLOCKS = 1
12141242
IN_IF_ELSE_FALSE_BLOCKS = 2

python/paddle/fluid/layers/io.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,26 @@ def read_file(file_obj):
587587

588588

589589
class Preprocessor(object):
590+
"""
591+
A block for data pre-processing in reader.
592+
593+
Args:
594+
reader (Variable): A reader variable.
595+
name (str, default None): The name of the reader.
596+
597+
Examples:
598+
.. code-block:: python
599+
600+
preprocessor = fluid.layers.io.Preprocessor(reader=reader)
601+
with preprocessor.block():
602+
img, lbl = preprocessor.inputs()
603+
img_out = img / 2
604+
lbl_out = lbl + 1
605+
preprocessor.outputs(img_out, lbl_out)
606+
607+
data_file = fluid.layers.io.double_buffer(preprocessor())
608+
609+
"""
590610
BEFORE_SUB_BLOCK = 0
591611
IN_SUB_BLOCK = 1
592612
AFTER_SUB_BLOCK = 2

0 commit comments

Comments
 (0)