zzangjinsun / NLSPN_ECCV20

Park et al., Non-Local Spatial Propagation Network for Depth Completion, ECCV, 2020
MIT License
321 stars 57 forks source link

question about code #14

Closed Xuanmeng-Zhang closed 3 years ago

Xuanmeng-Zhang commented 3 years ago

Hi, Park, I feel confused about the two-line code in nlspnmode.py as follows.

        offset_tmp[:, 0, :, :] = offset_tmp[:, 0, :, :] + hh - (self.k_f - 1) / 2
        offset_tmp[:, 1, :, :] = offset_tmp[:, 1, :, :] + ww - (self.k_f - 1) / 2

Can you explain the function of the two lines?What happens if I remove the two lines?

zzangjinsun commented 3 years ago

Hi @Xuanmeng-Zhang,

this process ensures offsets are initialized to a conventional 8-neighbor setup (i.e., 3x3 neighbors) because depending on the index, (hh - (self.k_f - 1) / 2, ww - (self.k_f - 1) / 2) falls into (-1, -1) to (1, 1).

I think you can remove these two lines and it makes the network learn all the neighbors' offset from zero without any initial values.

Hope this explanation is helpful for your understanding!

Xuanmeng-Zhang commented 3 years ago

Thank you for your answer. I get it!