ajabri / videowalk

Repository for "Space-Time Correspondence as a Contrastive Random Walk" (NeurIPS 2020)

Home Page:http://ajabri.github.io/videowalk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why is zero-loss-cycle always part of loss computation?

vadimkantorov opened this issue · comments

https://github.com/ajabri/videowalk/blob/master/code/model.py#L171 :
xents = [torch.tensor([0.]).to(self.args.device)]
loss = sum(xents)/max(1, len(xents)-1)

Is it just to have something evaluated to zero if there are no walks? In what case does this happen in practice?

Thank you @ajabri !

Hi @vadimkantorov,

Yes, I believe that's the reason for the line, but it can be removed! With the existing code, this only happens if your sequence is too short and no cycles are compute (I believe with sequence leng <= 2).

Hi @ajabri, thanks a lot for sharing your code! Is there any particular reason why you enforce that subsequence length must be >2 in order to take that cycle into account? I'm talking about line 147 of model.py, where range starts from 1: for i in list(range(1, len(A12s))): .... Why not starting from 0?