提交 1776293a 编写于 作者: H huangjun12 提交者: chajchaj

replace matmul to matmul_v2, expand to expand_v2

上级 6d45d8da
......@@ -1717,7 +1717,7 @@ def npair_loss(anchor, positive, labels, l2_reg=0.002):
batch_size = labels.shape[0]
labels = nn.reshape(labels, shape=[batch_size, 1])
labels = nn.expand(labels, expand_times=[1, batch_size])
labels = paddle.tile(labels, repeat_times=[1, batch_size])
labels = equal(labels, nn.transpose(labels, perm=[1, 0])).astype('float32')
labels = labels / nn.reduce_sum(labels, dim=1, keep_dim=True)
......@@ -1726,7 +1726,7 @@ def npair_loss(anchor, positive, labels, l2_reg=0.002):
+ nn.reduce_mean(nn.reduce_sum(square(positive), 1))
l2loss = l2loss * Beta * l2_reg
similarity_matrix = nn.matmul(
similarity_matrix = paddle.matmul(
anchor, positive, transpose_x=False, transpose_y=True)
softmax_ce = softmax_with_cross_entropy(
logits=similarity_matrix, label=labels, soft_label=True)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册