提交 66ea7184 编写于 作者: H haowang101779990

en api improve format Dec 27

test=develop
上级 988bc2b5
...@@ -272,8 +272,7 @@ class DataFeeder(object): ...@@ -272,8 +272,7 @@ class DataFeeder(object):
dict: the result of conversion. dict: the result of conversion.
Raises: Raises:
ValueError: If drop_last is False and the data batch which cannot ValueError: If drop_last is False and the data batch which cannot fit for devices.
fit for devices.
""" """
def __reader_creator__(): def __reader_creator__():
......
...@@ -1646,8 +1646,8 @@ class Program(object): ...@@ -1646,8 +1646,8 @@ class Program(object):
parameters, e.g., :code:`trainable`, :code:`optimize_attr`, need parameters, e.g., :code:`trainable`, :code:`optimize_attr`, need
to print. to print.
Returns Returns:
(str): The debug string. str : The debug string.
Raises: Raises:
ValueError: If any of required fields is not set and throw_on_error is ValueError: If any of required fields is not set and throw_on_error is
......
...@@ -1452,6 +1452,7 @@ class DynamicRNN(object): ...@@ -1452,6 +1452,7 @@ class DynamicRNN(object):
def step_input(self, x): def step_input(self, x):
""" """
Mark a sequence as a dynamic RNN input. Mark a sequence as a dynamic RNN input.
Args: Args:
x(Variable): The input sequence. x(Variable): The input sequence.
...@@ -1505,6 +1506,7 @@ class DynamicRNN(object): ...@@ -1505,6 +1506,7 @@ class DynamicRNN(object):
""" """
Mark a variable as a RNN input. The input will not be scattered into Mark a variable as a RNN input. The input will not be scattered into
time steps. time steps.
Args: Args:
x(Variable): The input variable. x(Variable): The input variable.
...@@ -1629,13 +1631,11 @@ class DynamicRNN(object): ...@@ -1629,13 +1631,11 @@ class DynamicRNN(object):
Args: Args:
init(Variable|None): The initialized variable. init(Variable|None): The initialized variable.
shape(list|tuple): The memory shape. NOTE the shape does not contain shape(list|tuple): The memory shape. NOTE the shape does not contain batch_size.
batch_size.
value(float): the initalized value. value(float): the initalized value.
need_reorder(bool): True if the initialized memory depends on the need_reorder(bool): True if the initialized memory depends on the input sample.
input sample.
dtype(str|numpy.dtype): The data type of the initialized memory. dtype(str|numpy.dtype): The data type of the initialized memory.
...@@ -1714,6 +1714,7 @@ class DynamicRNN(object): ...@@ -1714,6 +1714,7 @@ class DynamicRNN(object):
""" """
Update the memory from ex_mem to new_mem. NOTE that the shape and data Update the memory from ex_mem to new_mem. NOTE that the shape and data
type of :code:`ex_mem` and :code:`new_mem` must be same. type of :code:`ex_mem` and :code:`new_mem` must be same.
Args: Args:
ex_mem(Variable): the memory variable. ex_mem(Variable): the memory variable.
new_mem(Variable): the plain variable generated in RNN block. new_mem(Variable): the plain variable generated in RNN block.
......
...@@ -65,7 +65,7 @@ def rpn_target_assign(bbox_pred, ...@@ -65,7 +65,7 @@ def rpn_target_assign(bbox_pred,
rpn_negative_overlap=0.3, rpn_negative_overlap=0.3,
use_random=True): use_random=True):
""" """
** Target Assign Layer for region proposal network (RPN) in Faster-RCNN detection. ** **Target Assign Layer for region proposal network (RPN) in Faster-RCNN detection.**
This layer can be, for given the Intersection-over-Union (IoU) overlap This layer can be, for given the Intersection-over-Union (IoU) overlap
between anchors and ground truth boxes, to assign classification and between anchors and ground truth boxes, to assign classification and
...@@ -148,6 +148,7 @@ def rpn_target_assign(bbox_pred, ...@@ -148,6 +148,7 @@ def rpn_target_assign(bbox_pred,
cls_logits=cls_logits, cls_logits=cls_logits,
anchor_box=anchor_box, anchor_box=anchor_box,
gt_boxes=gt_boxes) gt_boxes=gt_boxes)
""" """
helper = LayerHelper('rpn_target_assign', **locals()) helper = LayerHelper('rpn_target_assign', **locals())
...@@ -1525,20 +1526,23 @@ def anchor_generator(input, ...@@ -1525,20 +1526,23 @@ def anchor_generator(input,
anchors, e.g. [0.5, 1.0, 2.0]. anchors, e.g. [0.5, 1.0, 2.0].
variance(list|tuple): The variances to be used in box regression deltas. variance(list|tuple): The variances to be used in box regression deltas.
Default:[0.1, 0.1, 0.2, 0.2]. Default:[0.1, 0.1, 0.2, 0.2].
stride(list|turple): The anchors stride across width and height, stride(list|turple): The anchors stride across width and height,e.g. [16.0, 16.0]
e.g. [16.0, 16.0]
offset(float): Prior boxes center offset. Default: 0.5 offset(float): Prior boxes center offset. Default: 0.5
name(str): Name of the prior box op. Default: None. name(str): Name of the prior box op. Default: None.
Returns: Returns:
Anchors(Variable): The output anchors with a layout of [H, W, num_anchors, 4]. Anchors(Variable),Variances(Variable):
H is the height of input, W is the width of input,
num_anchors is the box count of each position. two variables:
- Anchors(Variable): The output anchors with a layout of [H, W, num_anchors, 4]. \
H is the height of input, W is the width of input, \
num_anchors is the box count of each position. \
Each anchor is in (xmin, ymin, xmax, ymax) format an unnormalized. Each anchor is in (xmin, ymin, xmax, ymax) format an unnormalized.
Variances(Variable): The expanded variances of anchors - Variances(Variable): The expanded variances of anchors \
with a layout of [H, W, num_priors, 4]. with a layout of [H, W, num_priors, 4]. \
H is the height of input, W is the width of input H is the height of input, W is the width of input \
num_anchors is the box count of each position. num_anchors is the box count of each position. \
Each variance is in (xcenter, ycenter, w, h) format. Each variance is in (xcenter, ycenter, w, h) format.
...@@ -1748,7 +1752,7 @@ def generate_proposals(scores, ...@@ -1748,7 +1752,7 @@ def generate_proposals(scores,
eta=1.0, eta=1.0,
name=None): name=None):
""" """
** Generate proposal Faster-RCNN ** **Generate proposal Faster-RCNN**
This operation proposes RoIs according to each box with their probability to be a foreground object and This operation proposes RoIs according to each box with their probability to be a foreground object and
the box can be calculated by anchors. Bbox_deltais and scores to be an object are the output of RPN. Final proposals the box can be calculated by anchors. Bbox_deltais and scores to be an object are the output of RPN. Final proposals
...@@ -1762,7 +1766,6 @@ def generate_proposals(scores, ...@@ -1762,7 +1766,6 @@ def generate_proposals(scores,
4. Remove predicted boxes with small area. 4. Remove predicted boxes with small area.
5. Apply NMS to get final proposals as output. 5. Apply NMS to get final proposals as output.
Args: Args:
scores(Variable): A 4-D Tensor with shape [N, A, H, W] represents the probability for each box to be an object. scores(Variable): A 4-D Tensor with shape [N, A, H, W] represents the probability for each box to be an object.
N is batch size, A is number of anchors, H and W are height and width of the feature map. N is batch size, A is number of anchors, H and W are height and width of the feature map.
...@@ -1777,6 +1780,7 @@ def generate_proposals(scores, ...@@ -1777,6 +1780,7 @@ def generate_proposals(scores,
nms_thresh(float): Threshold in NMS, 0.5 by default. nms_thresh(float): Threshold in NMS, 0.5 by default.
min_size(float): Remove predicted boxes with either height or width < min_size. 0.1 by default. min_size(float): Remove predicted boxes with either height or width < min_size. 0.1 by default.
eta(float): Apply in adaptive NMS, if adaptive threshold > 0.5, adaptive_threshold = adaptive_threshold * eta in each iteration. eta(float): Apply in adaptive NMS, if adaptive threshold > 0.5, adaptive_threshold = adaptive_threshold * eta in each iteration.
""" """
helper = LayerHelper('generate_proposals', **locals()) helper = LayerHelper('generate_proposals', **locals())
......
...@@ -949,12 +949,11 @@ def shuffle(reader, buffer_size): ...@@ -949,12 +949,11 @@ def shuffle(reader, buffer_size):
is determined by argument buf_size. is determined by argument buf_size.
Args: Args:
param reader: the original reader whose output will be shuffled. reader(callable): the original reader whose output will be shuffled.
type reader: callable buf_size(int): shuffle buffer size.
param buf_size: shuffle buffer size.
type buf_size: int Returns:
return: the new reader whose output is shuffled. callable: the new reader whose output is shuffled.
rtype: callable
""" """
return __create_unshared_decorated_reader__( return __create_unshared_decorated_reader__(
'create_shuffle_reader', reader, {'buffer_size': int(buffer_size)}) 'create_shuffle_reader', reader, {'buffer_size': int(buffer_size)})
......
此差异已折叠。
...@@ -393,9 +393,6 @@ def fill_constant_batch_size_like(input, ...@@ -393,9 +393,6 @@ def fill_constant_batch_size_like(input,
It also sets *stop_gradient* to True. It also sets *stop_gradient* to True.
>>> data = fluid.layers.fill_constant_batch_size_like(
>>> input=like, shape=[1], value=0, dtype='int64')
Args: Args:
input(${input_type}): ${input_comment}. input(${input_type}): ${input_comment}.
...@@ -411,6 +408,14 @@ def fill_constant_batch_size_like(input, ...@@ -411,6 +408,14 @@ def fill_constant_batch_size_like(input,
Returns: Returns:
${out_comment}. ${out_comment}.
Examples:
.. code-block:: python
data = fluid.layers.fill_constant_batch_size_like(
input=like, shape=[1], value=0, dtype='int64')
""" """
helper = LayerHelper("fill_constant_batch_size_like", **locals()) helper = LayerHelper("fill_constant_batch_size_like", **locals())
out = helper.create_variable_for_type_inference(dtype=dtype) out = helper.create_variable_for_type_inference(dtype=dtype)
......
...@@ -362,7 +362,7 @@ class ChunkEvaluator(MetricBase): ...@@ -362,7 +362,7 @@ class ChunkEvaluator(MetricBase):
compute the precision recall and F1-score using the accumulated counter compute the precision recall and F1-score using the accumulated counter
numbers. numbers.
For some basics of chunking, please refer to For some basics of chunking, please refer to
'Chunking with Support Vector Machines <https://aclanthology.info/pdf/N/N01/N01-1025.pdf>'. `Chunking with Support Vector Machines <https://aclanthology.info/pdf/N/N01/N01-1025.pdf>`_ .
ChunkEvalEvaluator computes the precision, recall, and F1-score of chunk detection, ChunkEvalEvaluator computes the precision, recall, and F1-score of chunk detection,
and supports IOB, IOE, IOBES and IO (also known as plain) tagging schemes. and supports IOB, IOE, IOBES and IO (also known as plain) tagging schemes.
...@@ -391,6 +391,7 @@ class ChunkEvaluator(MetricBase): ...@@ -391,6 +391,7 @@ class ChunkEvaluator(MetricBase):
def update(self, num_infer_chunks, num_label_chunks, num_correct_chunks): def update(self, num_infer_chunks, num_label_chunks, num_correct_chunks):
""" """
Update the states based on the layers.chunk_eval() ouputs. Update the states based on the layers.chunk_eval() ouputs.
Args: Args:
num_infer_chunks(int|numpy.array): The number of chunks in Inference on the given minibatch. num_infer_chunks(int|numpy.array): The number of chunks in Inference on the given minibatch.
num_label_chunks(int|numpy.array): The number of chunks in Label on the given mini-batch. num_label_chunks(int|numpy.array): The number of chunks in Label on the given mini-batch.
...@@ -450,9 +451,9 @@ class EditDistance(MetricBase): ...@@ -450,9 +451,9 @@ class EditDistance(MetricBase):
distance, instance_error = distance_evaluator.eval() distance, instance_error = distance_evaluator.eval()
In the above example: In the above example:
'distance' is the average of the edit distance in a pass.
'instance_error' is the instance error rate in a pass. - 'distance' is the average of the edit distance in a pass.
- 'instance_error' is the instance error rate in a pass.
""" """
...@@ -567,12 +568,15 @@ class DetectionMAP(object): ...@@ -567,12 +568,15 @@ class DetectionMAP(object):
Calculate the detection mean average precision (mAP). Calculate the detection mean average precision (mAP).
The general steps are as follows: The general steps are as follows:
1. calculate the true positive and false positive according to the input 1. calculate the true positive and false positive according to the input
of detection and labels. of detection and labels.
2. calculate mAP value, support two versions: '11 point' and 'integral'. 2. calculate mAP value, support two versions: '11 point' and 'integral'.
Please get more information from the following articles: Please get more information from the following articles:
https://sanchom.wordpress.com/tag/average-precision/ https://sanchom.wordpress.com/tag/average-precision/
https://arxiv.org/abs/1512.02325 https://arxiv.org/abs/1512.02325
Args: Args:
...@@ -615,8 +619,10 @@ class DetectionMAP(object): ...@@ -615,8 +619,10 @@ class DetectionMAP(object):
In the above example: In the above example:
'cur_map_v' is the mAP of current mini-batch. - 'cur_map_v' is the mAP of current mini-batch.
'accum_map_v' is the accumulative mAP of one pass. - 'accum_map_v' is the accumulative mAP of one pass.
""" """
def __init__(self, def __init__(self,
......
...@@ -125,14 +125,23 @@ def slice_variable(var_list, slice_count, min_block_size): ...@@ -125,14 +125,23 @@ def slice_variable(var_list, slice_count, min_block_size):
class DistributeTranspilerConfig(object): class DistributeTranspilerConfig(object):
""" """
Args: .. py:attribute:: slice_var_up (bool)
slice_var_up (bool): Do Tensor slice for pservers, default is True.
split_method (PSDispatcher): RoundRobin or HashName can be used Do Tensor slice for pservers, default is True.
try to choose the best method to balance loads for pservers.
min_block_size (int): Minimum splitted element number in block. .. py:attribute:: split_method (PSDispatcher)
According:https://github.com/PaddlePaddle/Paddle/issues/8638#issuecomment-369912156
RoundRobin or HashName can be used.
Try to choose the best method to balance loads for pservers.
.. py:attribute:: min_block_size (int)
Minimum number of splitted elements in block.
According to : https://github.com/PaddlePaddle/Paddle/issues/8638#issuecomment-369912156
We can use bandwidth effiently when data size is larger than 2MB.If you We can use bandwidth effiently when data size is larger than 2MB.If you
want to change it, please be sure you see the slice_variable function. want to change it, please be sure you have read the slice_variable function.
""" """
slice_var_up = True slice_var_up = True
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册