WuJie1010 / Temporally-language-grounding

A Pytorch implemention for some state-of-the-art models for" Temporally Language Grounding in Untrimmed Videos"
96 stars 21 forks source link

Loss function #4

Closed yufansong closed 5 years ago

yufansong commented 5 years ago
  1. In the code, you didn't add Location/IoU loss, what you do is just create the variables without assigning any value. Actually, if I try to revise the loss function into correct code. I find the performance will decrease largely.

  2. The policy loss function is always negative and what we want to do is minimum this loss rather than make it always increase. I was wondering the reason is reward value is always lower than state value(According to the A2C formula) or this is the bug of the code.

WuJie1010 commented 5 years ago
  1. (policy_loss + value_loss + iou_loss + loc_loss).backward(retain_graph = True) have added the loss. I find it achieves a comparable result with/without these two losses.
  2. It is an interesting phenomenon, I guess the reason is the reward value is always lower than state value.
yufansong commented 5 years ago

I mean you only have

locations = torch.zeros(opt.num_steps, batch_size, 2)

but without

locations[step, :] = location

so this part will have bug

loc_loss += (torch.abs(offset_norm[j][0].cpu() - locations[i][j][0]) + torch.abs(offset_norm[j][1].cpu() - locations[i][j][1]))
yufansong commented 5 years ago

For the policy loss part, I agree with you. I think the accumulated reward is too small, so the R is always lower than the state value.

WuJie1010 commented 5 years ago

I mean you only have

locations = torch.zeros(opt.num_steps, batch_size, 2)

but without

locations[step, :] = location

so this part will have bug

loc_loss += (torch.abs(offset_norm[j][0].cpu() - locations[i][j][0]) + torch.abs(offset_norm[j][1].cpu() - locations[i][j][1]))

oh~ your are right~ I will fix this bug~

yufansong commented 5 years ago

Also, the predict IoU should be fixed.

Predict_IoUs[step, :] = tIoU
yufansong commented 5 years ago

Your reply is so quick. I just was trying to pull the request to fix those two bugs, but you have already fixed one of it.

WuJie1010 commented 5 years ago

Your reply is so quick. I just was trying to pull the request to fix those two bugs, but you have already fixed one of it.

Thanks for your suggestions~ you can pull the request if you find other bugs~ Thanks~