@@ -5830,24 +5830,25 @@ def rank_loss(label, left, right, name=None):
5830
5830
5831
5831
def margin_rank_loss (label , left , right , margin = 0.1 , name = None ):
5832
5832
"""
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:
5835
5836
5836
5837
.. math::
5837
5838
5838
5839
rank\_loss &= max(0, -label * (left - right) + margin)
5839
5840
5840
5841
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
5845
5846
name (str|None): A name for this layer (optional). If set None, the layer
5846
5847
will be named automatically.
5847
5848
Returns:
5848
- list: The value of rank loss.
5849
+ list: The Variable of ranking loss.
5849
5850
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 .
5851
5852
Examples:
5852
5853
.. code-block:: python
5853
5854
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):
5862
5863
raise ValueError ("The left should be a Variable" )
5863
5864
if not (isinstance (right , Variable )):
5864
5865
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 )
5867
5868
helper .append_op (
5868
5869
type = 'margin_rank_loss' ,
5869
5870
inputs = {"Label" : label ,
0 commit comments