ClementPinard / FlowNetPytorch

Pytorch implementation of FlowNet by Dosovitskiy et al.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

out_corr = out_corr.view(b, ph * pw, h, w)/input1.size(1)

ljp1997 opened this issue · comments

hi, @ClementPinard,i can not understand why out_corr.view(b, ph * pw, h, w) divided by input1.size(1), this code appears in the line 50 of FlowNetPytorch/models/util.py,can you explain it

The dimension collate is get back to a regular 2D feature map, which is supposed to be a 4D tensor : B,C,H,W
The division by C (number of channels of input, i.e. input1.size(1), because input1 dimensions are B,C,H,W) is just a convention made by first author of flownet.

See original implementation of correlation layer in caffe : https://github.com/lmb-freiburg/flownet2/blob/master/src/caffe/layers/correlation_layer.cu

(note that they divide by kernel size too, but use a kernel size of 1)

The main motivation is then to be able to load weights from the caffe model and be able to have roughly get the same results as in caffe code.

But if you train from scratch, you don't need this division.

Thank you very much