-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fraction_positive increasing #51
Comments
I was facing the same issue with hard batching. I lowered the learning rate and made the change in hard batch function suggested in #18 (comment) |
I have a similar problem. I am using the batch-all strategy and my fraction of positive triplets is always 1.0. The loss function oscillates around the margin, but the fraction of positive triplets do not decrease. I've tried lowering the learning rate, but nothing happens. I've also checked that the embeddings do not collapse to a point. Edit: I solved the problem. I was giving tensors with wrong shape to the function batch_all_triplet_loss(). |
@laiadc I am struggling with the same issue, how do you solve it? I dont think that anything is wrong with the tensor I give. I am applying the code on my own dataset. |
@laiadc: Thanks for hinting towards the tensors' shapes. That was the issue for me as well. @kurehawaru: Here is what helped me to solve the issue. print()
print('labels.shape: {}'.format(labels.shape))
print('embeddings.shape: {}'.format(embeddings.shape)) The ouput I got was the following:
( Since the def batch_all_triplet_loss_caller(y_true, y_pred, margin=0.5):
loss, error = batch_all_triplet_loss(tf.squeeze(y_true), y_pred, margin)
return loss, error Hope that helps. |
I'm trying to use triplet loss train resnet on arbitrary datasets but I can't. When I train mnist using your repo, I see fraction_positive decreasing over time but then, for resnet it goes up instead. batch all and batch hard losses start way above margin and decrease over time to margin, making mean distance to be about zero.
First I thought my data is not sufficient for triplet loss but when I saw the very same pattern for mnist, I think there might be a problem somewhere.
The text was updated successfully, but these errors were encountered: