From 7f6ff6f5a90b4d085275bd066ed95e723832d061 Mon Sep 17 00:00:00 2001 From: minqiyang Date: Fri, 12 Oct 2018 10:46:44 +0800 Subject: [PATCH] Polish doc test=develop --- python/paddle/fluid/layers/nn.py | 44 ++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 3f7adc409..7261b3009 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -5830,25 +5830,31 @@ def rank_loss(label, left, right, name=None): def margin_rank_loss(label, left, right, margin=0.1, name=None): """ - **Margin Rank loss layer for rank problem** - Args: - label (Variable): Indicats whether left higher than (right + margin) or not. - left (Variable): rank score for left. - right (Variable): rank score for right. - margin (float): Indicates the margin to be added to right - name (str|None): A name for this layer (optional). If set None, the layer - will be named automatically. - Returns: - list: The value of rank loss. - Raises: - ValueError: Any of label, left, and right is not a variable. - Examples: - .. code-block:: python - label = fluid.layers.data(name="label", shape=[4, 1], dtype="float32") - left = fluid.layers.data(name="left", shape=[4, 1], dtype="float32") - right = fluid.layers.data(name="right", shape=[4, 1], dtype="float32") - out = fluid.layers.margin_rank_loss(label, left, right) - """ + Margin Rank loss layer for rank problem, which comparing left value and right value be passed in. + The rank loss can be defined as below equation: + + .. math:: + + rank\_loss &= max(0, -label * (left - right) + margin) + + Args: + label (Variable): Indicats whether left higher than (right + margin) or not. + left (Variable): rank score for left. + right (Variable): rank score for right. + margin (float): Indicates the margin to be added to right + name (str|None): A name for this layer (optional). If set None, the layer + will be named automatically. + Returns: + list: The value of rank loss. + Raises: + ValueError: Any of label, left, and right is not a variable. + Examples: + .. code-block:: python + label = fluid.layers.data(name="label", shape=[4, 1], dtype="float32") + left = fluid.layers.data(name="left", shape=[4, 1], dtype="float32") + right = fluid.layers.data(name="right", shape=[4, 1], dtype="float32") + out = fluid.layers.margin_rank_loss(label, left, right) + """ helper = LayerHelper('margin_rank_loss', **locals()) if not (isinstance(label, Variable)): raise ValueError("The label should be a Variable") -- GitLab