Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

triplet_loss problem #9

Open
XuShoweR opened this issue May 7, 2019 · 1 comment
Open

triplet_loss problem #9

XuShoweR opened this issue May 7, 2019 · 1 comment

Comments

@XuShoweR
Copy link

XuShoweR commented May 7, 2019

I want use your triplet_loss function to train a classification model with imagenet, and i got a mistake at triplet_loss.py line 70
dist_ap, relative_p_inds = torch.max((dist_mat * is_pos.float()).contiguous().view(N, -1), 1,keepdim=True)
if my label is [1, 1, 2, 3] then N=4 i got
RuntimeError: shape '[4, -1]' is invalid for input of size 6
if my label is [1, 1, 2, 2] and it worked
Is my understanding correct?Do I need to generate labels in this form[1,1,2,2]?

@earhian
Copy link
Owner

earhian commented May 8, 2019

Could you print dist_mat.shape and is_pos.shape?
By the way, you can refer to https://github.com/huanghoujing/AlignedReID-Re-Production-Pytorch/blob/master/aligned_reid/model/loss.py.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants