e384479872a16249fa89733e6194f650219dd05b,pyannote/audio/embedding/approaches/triplet_loss.py,TripletLoss,loss_y_fold,#TripletLoss#Any#Any#,230
Before Change
if (anchor == positive) or (y_anchor != y_positive):
continue
for negative, y_negative in enumerate(y):
// if same label, skip
if y_negative == y_positive:
continue
loss_ = distance[anchor, positive] - \
distance[anchor, negative]
if self.clamp == "positive":
loss_ = loss_ + self.margin * self.metric_max_
loss_ = ag_np.maximum(loss_, 0.)
elif self.clamp == "sigmoid":
loss_ = loss_ - self.margin * self.metric_max_
loss_ = 1. / (1. + ag_np.exp(-10. * loss_))
// do not use += because autograd does not support it
loss = loss + loss_
n_comparisons = n_comparisons + 1
return loss, n_comparisons
def loss_z(self, fX, y, n, *args):
Differentiable loss
After Change
if (anchor == positive) or (y_anchor != y_positive):
continue
for i, negative in enumerate(
self.triplet_sampling(y, anchor, positive,
distance=distance)):
// at most n_negative negative samples
if i + 1 > self.n_negative:
break
loss_ = self.triplet_loss(distance,
anchor,
positive,
negative=negative,
clamp=True)
// do not use += because autograd does not support it
loss = loss + loss_
n_comparisons = n_comparisons + 1
return loss, n_comparisons
def loss_z(self, fX, y, n, *args):
Differentiable loss
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 7
Instances
Project Name: pyannote/pyannote-audio
Commit Name: e384479872a16249fa89733e6194f650219dd05b
Time: 2017-07-10
Author: hbredin@users.noreply.github.com
File Name: pyannote/audio/embedding/approaches/triplet_loss.py
Class Name: TripletLoss
Method Name: loss_y_fold
Project Name: onnx/onnx-coreml
Commit Name: 624d14284e35d6ce9c371c39f7e387002ccf4913
Time: 2018-08-25
Author: aseem.elec@gmail.com
File Name: onnx_coreml/_transformers.py
Class Name: ImageScalerRemover
Method Name: __call__
Project Name: vatlab/SoS
Commit Name: ff5bbede0431e5296811dc57432a33a9a68942d0
Time: 2016-09-22
Author: ben.bog@gmail.com
File Name: pysos/dag.py
Class Name: SoS_DAG
Method Name: build