lyakaap / NetVLAD-pytorch

PyTorch implementation of NetVLAD & Online Hardest Triplet Loss.
MIT License
446 stars 88 forks source link

RuntimeError: result type Long can't be cast to the desired output type Bool #4

Open traveling121 opened 4 years ago

traveling121 commented 4 years ago

Could you please tell me why it shows "RuntimeError: result type Long can't be cast to the desired output type Bool" when running this code?

traveling121 commented 3 years ago
font{
    line-height: 1.6;
}
ul,ol{
    padding-left: 20px;
    list-style-position: inside;
}

Yes,  I have solved this problem but I met  another one that the loss can not converge to a value less than the margin.

On 12/1/2020 10:06,taylover-pei<notifications@github.com> wrote: 

Have you solved this problem?

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or unsubscribe.

baopmessi commented 3 years ago

How to solved this problem?

traveling121 commented 3 years ago
font{
    line-height: 1.6;
}
ul,ol{
    padding-left: 20px;
    list-style-position: inside;
}

    I changed some details in this file 'hard_triplet_loss.py', but I forget which one solved this problem. The changed file is attached here for you to refer. Hope this can help you.

On 12/22/2020 14:48,baopmessi<notifications@github.com> wrote: 

How to solved this problem?

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or unsubscribe.

zhangxiaopang88 commented 3 years ago

Hello, I also encountered this problem, which has not been solved yet. Could you send me a copy of your document, please? thank you.

zhangxiaopang88 commented 3 years ago

How to solved this problem? Hello, I also encountered this problem, which has not been solved yet. Could you send me a copy of your document, please? thank you.

traveling121 commented 3 years ago
font{
    line-height: 1.6;
}
ul,ol{
    padding-left: 20px;
    list-style-position: inside;
}

Sure, hope this can help you .

On 1/10/2021 17:27,zhangxiaopang88<notifications@github.com> wrote: 

How to solved this problem?

Hello, I also encountered this problem, which has not been solved yet. Could you send me a copy of your document, please? thank you.

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or unsubscribe.

yochaiye commented 3 years ago

Hi @Yolanda2020,

Can you please send me your solution too?

traveling121 commented 3 years ago
font{
    line-height: 1.6;
}
ul,ol{
    padding-left: 20px;
    list-style-position: inside;
}

On 1/26/2021 07:56,yochaiye<notifications@github.com> wrote: 

Hi @Yolanda2020, Can you please send me your solution too?

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.

5kyler commented 3 years ago

Hello @Yolanda2020, could you please send me your solution too?? thanks a lot.

JAaron9311 commented 3 years ago

Could you please tell me why it shows "RuntimeError: result type Long can't be cast to the desired output type Bool" when running this code?

def _get_triplet_mask(labels):
    device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

    # Check that i, j and k are distinct
    indices_equal = torch.eye(labels.size(0), dtype=torch.bool, device=labels.device)
    indices_not_equal = ~indices_equal
    i_not_equal_j = indices_not_equal.unsqueeze(2)
    i_not_equal_k = indices_not_equal.unsqueeze(1)
    j_not_equal_k = indices_not_equal.unsqueeze(0)

    distinct_indices = (i_not_equal_j & i_not_equal_k) & j_not_equal_k

    label_equal = labels.unsqueeze(0) == labels.unsqueeze(1)
    i_equal_j = label_equal.unsqueeze(2)
    i_equal_k = label_equal.unsqueeze(1)

    valid_labels = ~i_equal_k & i_equal_j
    mask = valid_labels & distinct_indices
    return mask.to(device)

you can use the above function to replace to original one.

5kyler commented 3 years ago

thank you so much😭😭😊😊👍👍👍👍👍

2021년 2월 14일 (일) 오후 10:21, JAaron9311 notifications@github.com님이 작성:

Could you please tell me why it shows "RuntimeError: result type Long can't be cast to the desired output type Bool" when running this code?

def _get_triplet_mask(labels): device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

Check that i, j and k are distinct

indices_equal = torch.eye(labels.size(0), dtype=torch.bool, device=labels.device) indices_not_equal = ~indices_equal i_not_equal_j = indices_not_equal.unsqueeze(2) i_not_equal_k = indices_not_equal.unsqueeze(1) j_not_equal_k = indices_not_equal.unsqueeze(0)

distinct_indices = (i_not_equal_j & i_not_equal_k) & j_not_equal_k

label_equal = labels.unsqueeze(0) == labels.unsqueeze(1) i_equal_j = label_equal.unsqueeze(2) i_equal_k = label_equal.unsqueeze(1)

valid_labels = ~i_equal_k & i_equal_j mask = valid_labels & distinct_indices return mask.to(device)

you can use the above function to replace to original one.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lyakaap/NetVLAD-pytorch/issues/4#issuecomment-778777153, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKCOPNOA7Q4X2UHBUFESFYDS67E4TANCNFSM4PNH6BCQ .

Dreamdusty commented 3 years ago

@Yolanda2020 ,hello, could you please send me the file --- 'hard-margin-triplet loss? I meet this problem, too. Thank you

traveling121 commented 3 years ago
font{
    line-height: 1.6;
}
ul,ol{
    padding-left: 20px;
    list-style-position: inside;
}

On 8/27/2021 ***@***.***> wrote: 

@Yolanda2020 ,hello, could you please send me the file --- 'hard-margin-triplet loss? I meet this problem, too. Thank you

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications on the go with GitHub Mobile for iOS or Android.

zhengyulau commented 3 years ago

Hi, I meet this problem too. Could you please send me your solution? Thanks a lot!

traveling121 commented 3 years ago
font{
    line-height: 1.6;
}
ul,ol{
    padding-left: 20px;
    list-style-position: inside;
}

On 9/30/2021 ***@***.***> wrote: 

Hi, I meet this problem too. Could you please send me your solution? Thanks a lot!

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications on the go with GitHub Mobile for iOS or Android.