princeton-vl / DPVO

Deep Patch Visual Odometry/SLAM
MIT License
610 stars 72 forks source link

How to understand the softagg for frame aggregation? #20

Open ZuoJiaxing opened 1 year ago

ZuoJiaxing commented 1 year ago

Hi, I've a problem understanding the index of edges when you perform the softagg for the frame aggregation: net = net + self.agg_ij(net, ii*12345 + jj) https://github.com/princeton-vl/DPVO/blob/3f65b72dee3c9ed36e7bdb6d106d0ade6d5fc118/dpvo/net.py#L88

In the paper, it is said that frame aggregation is performed on the edges sharing the same source and destination frames. How can it be "ii*12345 + jj"? It will be appreciated if you can explain it a little bit.

lahavlipson commented 1 year ago

The SoftAgg block aggregates edges with the same value in the second argument. "ii*12345 + jj" is the same for all edges with the same source and destination frames.

senecobis commented 1 year ago

Possibly a follow-up question. I was trying to understand the same softagg. I see that ii and jj are arrays with the same number inside e.g. ii=[0,0,0,...] and jj=[1,1,1,...] therefore is understandable that "ii*12345 + jj" has always the same value. What I didn’t get is why it is multiplied for a smilingly random number 12345.

lahavlipson commented 1 year ago

ii*12345 + jj simply maps a pair of integers, i and j, to single unique integer. The value of this number doesn't matter, torch.hash(ii, jj) would work just as well if such a function existed. See https://pytorch-scatter.readthedocs.io/en/1.4.0/composite/softmax.html#torch_scatter.composite.scatter_softmax

senecobis commented 1 year ago

It's clear thanks.