omoindrot / tensorflow-triplet-loss

Implementation of triplet loss in TensorFlow
https://omoindrot.github.io/triplet-loss
MIT License
1.12k stars 283 forks source link

Got Nan value when label's id is greater than 159 #62

Closed huawei-lin closed 2 years ago

huawei-lin commented 2 years ago

I am training a face recognition network with 3000 identities dataset, so the real label's id are in 0 ~ 2,999. Then I found that the triplet loss would get Nan value when the real label's id is greater than 159. So I re-arrange the real label to 0 ~ (num_classes_per_batch - 1), but it still don't work when the num_classes_per_batch > 160.

Before labels re-arrangement: image

After labels re-arrangement: image

In this case, I would like to increase the num_classes_per_batch, but it would get nan value when the num_classes_per_batch > 160.

huawei-lin commented 2 years ago

It is a mistake from my code. I am so sorry about that.