diff --git a/python/paddle/nn/functional/loss.py b/python/paddle/nn/functional/loss.py index 3f5637fa3922b99b5d5d640f3bd0a1cab997ca65..f1cc6c114713fe3ac80330727d7ec1a617ef088f 100755 --- a/python/paddle/nn/functional/loss.py +++ b/python/paddle/nn/functional/loss.py @@ -1159,8 +1159,9 @@ def margin_ranking_loss(input, check_variable_and_dtype(label, 'label', ['float32', 'float64'], 'margin_rank_loss') - out = paddle.subtract(other, input) - out = paddle.multiply(out, label) + out = paddle.subtract(input, other) + neg_label = paddle.neg(label) + out = paddle.multiply(neg_label, out) if margin != 0.0: margin_var = out.block.create_var(dtype=out.dtype)