RepNet-Pytorch icon indicating copy to clipboard operation
RepNet-Pytorch copied to clipboard

calculate the count value by denominator with " + 1e-1" make the value less than target

Open qrsforever opened this issue 3 years ago • 2 comments

https://github.com/confifu/RepNet-Pytorch/blob/b655b8090132499a29d2f4a595d174ba56ee033f/trainLoop.py#L149

raw:

                countpred = torch.sum((y2pred > 0) / (y1pred + 1e-1), 1)
                count = torch.sum((y2 > 0) / (y1 + 1e-1), 1)

changed:

                countpred = torch.sum((y2pred > 0) / torch.nn.functional.threshold(y1pred, 1e-1, 1e-1), 1)
                count = torch.sum((y2 > 0) / torch.nn.functional.threshold(y1, 1e-1, 1e-1), 1)

is it good?

qrsforever avatar Jun 08 '21 04:06 qrsforever

Yes, although when y1 < 1e-1 gradient won't flow at all, because y2>0 is not differentiable and 1e-1 is constant. You want the loss to be a differentiable function of the predicted value.

confifu avatar Jun 08 '21 05:06 confifu

https://github.com/confifu/RepNet-Pytorch/blob/b655b8090132499a29d2f4a595d174ba56ee033f/trainLoop.py#L149

raw:

                countpred = torch.sum((y2pred > 0) / (y1pred + 1e-1), 1)
                count = torch.sum((y2 > 0) / (y1 + 1e-1), 1)

changed:

                countpred = torch.sum((y2pred > 0) / torch.nn.functional.threshold(y1pred, 1e-1, 1e-1), 1)
                count = torch.sum((y2 > 0) / torch.nn.functional.threshold(y1, 1e-1, 1e-1), 1)

is it good?

Hi @qrsforever , Is there still an archive of the training data, jupyter book version of the test demo and pre-trained weights of this project, I am trying to reproduce this code but results are poor, hope I can get your help, appreciate it.

Cecilia-yu412 avatar Apr 02 '24 03:04 Cecilia-yu412