def squared_distance(self, anc, pos, neg):
"""
Compute anchor-positive distance and anchor-negative distance on
batches of anchors, positive, and negative samples.
"""
dist_pos = F.expand_dims(F.batch_l2_norm_squared(anc - pos), 1)
dist_neg = F.expand_dims(F.batch_l2_norm_squared(anc - neg), 1)
return dist_pos, dist_neg
评论列表
文章目录