ClementPinard / FlowNetTorch

Torch implementation of Fischer et al. FlowNet training code
30 stars 6 forks source link

Loss function #18

Closed bragilee closed 6 years ago

bragilee commented 6 years ago

Hi,

Thanks for your work.

I am wondering is the default loss function is L1 loss? And you use the L1 loss in multi-scale images, right?

And when I try to run the code with FlowNetS (not finetune), after 25 epochs, both the training and testing error are still more than 6.0, which is far large than yours. I am a bit confused about the performance.

Thanks. :)

ClementPinard commented 6 years ago

Hello, the default Loss, is the L1 EPE (End Point Error). namely, it's a mid point between L1 and L2, since the step is always of the same magnitude, no matter the value of EPE, but the direction is toward the target 2D flow value. It can be summed up as

EPE[i,j] = sqrt(sum(MSE(target[i,j], value[i,j]))

target[i,j] and value[i,j] are 2D values. Not gonna lie, I am not familiar with lua torch anymore, so it might be wrong (a more up to date code is available on Pytorch), but the EPE code is located here : https://github.com/ClementPinard/FlowNetTorch/blob/master/EPECriterion.lua

Now on the mutli scale factors, there had been some confusions, because I initially misread the original caffe training code. You can find a discussion about it here : https://github.com/ClementPinard/FlowNetPytorch/issues/17

Main elements of the discussion were :

IMO the most important here is to sum EPE, that way, higher resolution maps have a much larger equivalent multiscale weight.

bragilee commented 6 years ago

Hi,

Thank you so much for your details. Appreciate your discussion and work.

I read about the discussion and it is quite clear. So the loss in PyTorch version is updated to be consistent to original paper, right? And I saw that you have achieved better results. I would like to train from scratch, could I follow the hyper-parameters you shared in the discussion as a start?

Thank you so much. :)

ClementPinard commented 6 years ago

Yes, these are the hyperparameters that got me the best results !

bragilee commented 6 years ago

Thank you so much. :)