S3N
S3N copied to clipboard
Small bug in generate_map?
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?
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.
Cool, thanks