S3N icon indicating copy to clipboard operation
S3N copied to clipboard

Small bug in generate_map?

Open catalys1 opened this issue 5 years ago • 2 comments

See the following code, taken from generate_map in sss_net.py:

if p == 0:
    for i in peak_num:
        temp += score[i] * kernel_generate(self.radius(torch.sqrt(score[i])), H, (x[i].item(), y[i].item())).unsqueeze(0).unsqueeze(0).cuda()
        temp_w += 1/score[i] * \
        kernel_generate(self.radius_inv(torch.sqrt(score[i])), H, (x[i].item(), y[i].item())).unsqueeze(0).unsqueeze(0).cuda()
elif p == 1:
    for i in peak_num:
        rd = random.uniform(0, 1)
        if score[i] > rd:
            temp += score[i] * kernel_generate(self.radius(torch.sqrt(score[i])), H, (x[i].item(), y[i].item())).unsqueeze(0).unsqueeze(0).cuda()
        else:
            temp_w += 1/score[i] * \
            kernel_generate(self.radius_inv(torch.sqrt(score[i])), H, (x[i].item(), y[i].item())).unsqueeze(0).unsqueeze(0).cuda()
elif p == 2:
    index = score.index(max(score))
    temp += score[index] * kernel_generate(self.radius(score[index]), H, (x[index].item(), y[index].item())).unsqueeze(0).unsqueeze(0).cuda()
    
    index = score.index(min(score))
    temp_w += 1/score[index] * \
    kernel_generate(self.radius_inv(torch.sqrt(score[index])), H, (x[index].item(), y[index].item())).unsqueeze(0).unsqueeze(0).cuda()

In all but one instance, we take the square root of score[i] before passing it to self.radius or self.radius_inv. But in the case where p==2, we have

temp += score[index] * kernel_generate(self.radius(score[index]), H, (x[index].item(), y[index].item())).unsqueeze(0).unsqueeze(0).cuda()

and the square root is not taken. Is this a bug? Should the square root be taken here as well?

catalys1 avatar Oct 22 '20 18:10 catalys1

Sorry for my carelessness, the square root should be taken here. Indeed, the score of the maximun peak always is approximately equal to 1, so that whether taking the square root here or not will not affect the result. Thanks.

Yao-DD avatar Oct 23 '20 02:10 Yao-DD

Cool, thanks

catalys1 avatar Oct 28 '20 18:10 catalys1