Skip to content

Commit 5d0bf8b

Browse files
committed
Add API docs.
1 parent 431491a commit 5d0bf8b

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,32 @@ 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+
limit = layers.fill_constant_batch_size_like(
1222+
input=label, dtype='int64', shape=[1], value=5.0)
1223+
cond = layers.less_than(x=label, y=limit)
1224+
ie = layers.IfElse(cond)
1225+
with ie.true_block():
1226+
true_image = ie.input(image)
1227+
hidden = layers.fc(input=true_image, size=100, act='tanh')
1228+
prob = layers.fc(input=hidden, size=10, act='softmax')
1229+
ie.output(prob)
1230+
1231+
with ie.false_block():
1232+
false_image = ie.input(image)
1233+
hidden = layers.fc(input=false_image, size=200, act='tanh')
1234+
prob = layers.fc(input=hidden, size=10, act='softmax')
1235+
ie.output(prob)
1236+
prob = ie()
1237+
"""
12121238
OUT_IF_ELSE_BLOCKS = 0
12131239
IN_IF_ELSE_TRUE_BLOCKS = 1
12141240
IN_IF_ELSE_FALSE_BLOCKS = 2

python/paddle/fluid/layers/io.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,25 @@ 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+
preprocessor = fluid.layers.io.Preprocessor(reader=reader)
600+
with preprocessor.block():
601+
img, lbl = preprocessor.inputs()
602+
img_out = img / 2
603+
lbl_out = lbl + 1
604+
preprocessor.outputs(img_out, lbl_out)
605+
606+
data_file = fluid.layers.io.double_buffer(preprocessor())
607+
608+
"""
590609
BEFORE_SUB_BLOCK = 0
591610
IN_SUB_BLOCK = 1
592611
AFTER_SUB_BLOCK = 2

0 commit comments

Comments
 (0)