NetVLAD-pytorch icon indicating copy to clipboard operation
NetVLAD-pytorch copied to clipboard

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

Open traveling121 opened this issue 4 years ago • 15 comments

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 avatar Jul 30 '20 09:07 traveling121

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<[email protected]> 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.

traveling121 avatar Dec 05 '20 13:12 traveling121

How to solved this problem?

baopmessi avatar Dec 22 '20 06:12 baopmessi

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<[email protected]> 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.

traveling121 avatar Dec 30 '20 00:12 traveling121

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 avatar Jan 10 '21 09:01 zhangxiaopang88

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.

zhangxiaopang88 avatar Jan 10 '21 09:01 zhangxiaopang88

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<[email protected]> 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.

traveling121 avatar Jan 11 '21 03:01 traveling121

Hi @Yolanda2020,

Can you please send me your solution too?

yochaiye avatar Jan 25 '21 23:01 yochaiye

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




    
        
    


    
        
    


    
    

    


On 1/26/2021 07:56,yochaiye<[email protected]> 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.

traveling121 avatar Jan 28 '21 13:01 traveling121

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

5kyler avatar Feb 05 '21 09:02 5kyler

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.

JAaron9311 avatar Feb 14 '21 13:02 JAaron9311

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

2021년 2월 14일 (일) 오후 10:21, JAaron9311 [email protected]님이 작성:

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 .

5kyler avatar Feb 14 '21 13:02 5kyler

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

Dreamdusty avatar Aug 27 '21 06:08 Dreamdusty

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.

traveling121 avatar Aug 27 '21 07:08 traveling121

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

zhengyulau avatar Sep 30 '21 09:09 zhengyulau

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.

traveling121 avatar Sep 30 '21 10:09 traveling121