Skip to content

Commit cafdeb0

Browse files
author
Yibing Liu
committed
Fix docs for detection_output & target_assign
1 parent 67dc5c7 commit cafdeb0

File tree

2 files changed

+42
-24
lines changed

2 files changed

+42
-24
lines changed

python/paddle/fluid/layers/detection.py

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ class number, M is number of bounding boxes. For each category
9797
nms_eta(float): The parameter for adaptive NMS.
9898
9999
Returns:
100-
Variable: The detection outputs is a LoDTensor with shape [No, 6].
100+
Variable:
101+
102+
The detection outputs is a LoDTensor with shape [No, 6].
101103
Each row has six values: [label, confidence, xmin, ymin, xmax, ymax].
102104
`No` is the total number of detections in this mini-batch. For each
103105
instance, the offsets in first dimension are called LoD, the offset
@@ -110,15 +112,15 @@ class number, M is number of bounding boxes. For each category
110112
Examples:
111113
.. code-block:: python
112114
113-
pb = layers.data(name='prior_box', shape=[10, 4],
115+
pb = layers.data(name='prior_box', shape=[10, 4],
114116
append_batch_size=False, dtype='float32')
115-
pbv = layers.data(name='prior_box_var', shape=[10, 4],
117+
pbv = layers.data(name='prior_box_var', shape=[10, 4],
116118
append_batch_size=False, dtype='float32')
117-
loc = layers.data(name='target_box', shape=[2, 21, 4],
119+
loc = layers.data(name='target_box', shape=[2, 21, 4],
118120
append_batch_size=False, dtype='float32')
119-
scores = layers.data(name='scores', shape=[2, 21, 10],
121+
scores = layers.data(name='scores', shape=[2, 21, 10],
120122
append_batch_size=False, dtype='float32')
121-
nmsed_outs = fluid.layers.detection_output(scores=scores,
123+
nmsed_outs = fluid.layers.detection_output(scores=scores,
122124
loc=loc,
123125
prior_box=pb,
124126
prior_box_var=pbv)
@@ -296,8 +298,6 @@ def target_assign(input,
296298
mismatch_value=None,
297299
name=None):
298300
"""
299-
**Target assigner operator**
300-
301301
This operator can be, for given the target bounding boxes or labels,
302302
to assign classification and regression targets to each prediction as well as
303303
weights to prediction. The weights is used to specify which prediction would
@@ -311,20 +311,24 @@ def target_assign(input,
311311
312312
1. Assigning all outpts based on `match_indices`:
313313
314-
If id = match_indices[i][j] > 0,
314+
.. code-block:: text
315+
316+
If id = match_indices[i][j] > 0,
315317
316-
out[i][j][0 : K] = X[lod[i] + id][j % P][0 : K]
317-
out_weight[i][j] = 1.
318+
out[i][j][0 : K] = X[lod[i] + id][j % P][0 : K]
319+
out_weight[i][j] = 1.
318320
319-
Otherwise,
321+
Otherwise,
320322
321-
out[j][j][0 : K] = {mismatch_value, mismatch_value, ...}
322-
out_weight[i][j] = 0.
323+
out[j][j][0 : K] = {mismatch_value, mismatch_value, ...}
324+
out_weight[i][j] = 0.
323325
324326
2. Assigning out_weight based on `neg_indices` if `neg_indices` is provided:
325327
326328
Assumed that the row offset for each instance in `neg_indices` is called neg_lod,
327329
for i-th instance and each `id` of neg_indices in this instance:
330+
331+
.. code-block:: text
328332
329333
out[i][id][0 : K] = {mismatch_value, mismatch_value, ...}
330334
out_weight[i][id] = 1.0
@@ -341,10 +345,23 @@ def target_assign(input,
341345
mismatch_value (float32): Fill this value to the mismatched location.
342346
343347
Returns:
344-
out (Variable): The output is a 3D Tensor with shape [N, P, K],
345-
N and P is the same as they are in `neg_indices`, K is the
346-
same as it in input of X. If `match_indices[i][j]`.
347-
out_weight (Variable): The weight for output with the shape of [N, P, 1].
348+
tuple:
349+
350+
A tuple(out, out_weight) is returned. out is a 3D Tensor with
351+
shape [N, P, K], N and P is the same as they are in
352+
`neg_indices`, K is the same as it in input of X. If
353+
`match_indices[i][j]`. out_weight is the weight for output with
354+
the shape of [N, P, 1].
355+
356+
Examples:
357+
358+
.. code-block:: python
359+
360+
matched_indices, matched_dist = fluid.layers.bipartite_match(iou)
361+
gt = layers.data(
362+
name='gt', shape=[1, 1], dtype='int32', lod_level=1)
363+
trg, trg_weight = layers.target_assign(
364+
gt, matched_indices, mismatch_value=0)
348365
"""
349366
helper = LayerHelper('target_assign', **locals())
350367
out = helper.create_tmp_variable(dtype=input.dtype)

python/paddle/fluid/layers/nn.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3466,7 +3466,9 @@ def nce(input,
34663466
input (Variable): input variable.
34673467
label (Variable): label.
34683468
num_total_classes (int):${num_total_classes_comment}
3469-
sample_weight (int): ${sample_weight_comment}
3469+
sample_weight (Variable|None): A Variable of shape [batch_size, 1]
3470+
storing a weight for each sample. The default weight for each
3471+
sample is 1.0.
34703472
param_attr (ParamAttr|None): attributes for parameter
34713473
bias_attr (ParamAttr|None): attributes for bias
34723474
num_neg_samples (int): ${num_neg_samples_comment}
@@ -4638,10 +4640,6 @@ def random_crop(x, shape, seed=None):
46384640
"""
46394641
${comment}
46404642
4641-
Examples:
4642-
>>> img = fluid.layers.data("img", [3, 256, 256])
4643-
>>> cropped_img = fluid.layers.random_crop(img, shape=[3, 224, 224])
4644-
46454643
Args:
46464644
x(${x_type}): ${x_comment}
46474645
shape(${shape_type}): ${shape_comment}
@@ -4650,7 +4648,10 @@ def random_crop(x, shape, seed=None):
46504648
46514649
Returns:
46524650
${out_comment}
4653-
4651+
4652+
Examples:
4653+
>>> img = fluid.layers.data("img", [3, 256, 256])
4654+
>>> cropped_img = fluid.layers.random_crop(img, shape=[3, 224, 224])
46544655
"""
46554656
helper = LayerHelper("random_crop", **locals())
46564657
dtype = helper.input_dtype()

0 commit comments

Comments
 (0)