confifu / RepNet-Pytorch

Temporal repetition counting
40 stars 9 forks source link

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

Open qrsforever opened 3 years ago

qrsforever commented 3 years ago

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?

confifu commented 3 years ago

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.

Cecilia-yu412 commented 6 months ago

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.