From d3656ff30457f8333f7a556865eedd8dba3800a9 Mon Sep 17 00:00:00 2001 From: ceci3 <592712189@qq.com> Date: Sat, 9 Mar 2019 06:04:07 +0000 Subject: [PATCH] test=develop test=develop --- python/paddle/fluid/layers/nn.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index a546864f5c..0c918cf677 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -10695,13 +10695,11 @@ def npair_loss(anchor, positive, labels, l2_reg=0.002): labels = reshape(labels, shape=[batch_size, 1], inplace=True) labels = expand(labels, expand_times=[1, batch_size]) - labels = control_flow.equal( - labels, transpose( - labels, perm=[1, 0])).astype('float32') + labels = equal(labels, transpose(labels, perm=[1, 0])).astype('float32') labels = labels / reduce_sum(labels, dim=1, keep_dim=True) - l2loss = reduce_mean(reduce_sum(ops.square(anchor), 1)) \ - + reduce_mean(reduce_sum(ops.square(positive), 1)) + l2loss = reduce_mean(reduce_sum(square(anchor), 1)) \ + + reduce_mean(reduce_sum(square(positive), 1)) l2loss = l2loss * Beta * l2_reg similarity_matrix = matmul( -- GitLab