Skip to content

Commit a7cae62

Browse files
committed
Polish code
test=develop
1 parent 7f6ff6f commit a7cae62

File tree

1 file changed

+11
-10
lines changed
  • python/paddle/fluid/layers

1 file changed

+11
-10
lines changed

python/paddle/fluid/layers/nn.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5830,24 +5830,25 @@ def rank_loss(label, left, right, name=None):
58305830

58315831
def margin_rank_loss(label, left, right, margin=0.1, name=None):
58325832
"""
5833-
Margin Rank loss layer for rank problem, which comparing left value and right value be passed in.
5834-
The rank loss can be defined as below equation:
5833+
Margin Ranking Loss Layer for ranking problem,
5834+
which compare left score and right score passed in.
5835+
The ranking loss can be defined as following equation:
58355836
58365837
.. math::
58375838
58385839
rank\_loss &= max(0, -label * (left - right) + margin)
58395840
58405841
Args:
5841-
label (Variable): Indicats whether left higher than (right + margin) or not.
5842-
left (Variable): rank score for left.
5843-
right (Variable): rank score for right.
5844-
margin (float): Indicates the margin to be added to right
5842+
label (Variable): Indicates whether the left is ranked higher than the right or not.
5843+
left (Variable): ranking score for left.
5844+
right (Variable): ranking score for right.
5845+
margin (float): Indicates the given margin to be added to right
58455846
name (str|None): A name for this layer (optional). If set None, the layer
58465847
will be named automatically.
58475848
Returns:
5848-
list: The value of rank loss.
5849+
list: The Variable of ranking loss.
58495850
Raises:
5850-
ValueError: Any of label, left, and right is not a variable.
5851+
ValueError: Any of label, left, and right is not a Variable.
58515852
Examples:
58525853
.. code-block:: python
58535854
label = fluid.layers.data(name="label", shape=[4, 1], dtype="float32")
@@ -5862,8 +5863,8 @@ def margin_rank_loss(label, left, right, margin=0.1, name=None):
58625863
raise ValueError("The left should be a Variable")
58635864
if not (isinstance(right, Variable)):
58645865
raise ValueError("The right should be a Variable")
5865-
out = helper.create_tmp_variable("float32")
5866-
act = helper.create_tmp_variable("float32")
5866+
out = helper.create_tmp_variable(left.dtype)
5867+
act = helper.create_tmp_variable(left.dtype)
58675868
helper.append_op(
58685869
type='margin_rank_loss',
58695870
inputs={"Label": label,

0 commit comments

Comments
 (0)