jzengust / RGBD2Normal

Code for Deep Surface Normal Estimation with Hierarchical RGB-D Fusion (CVPR2019)
70 stars 12 forks source link

A question about hybird loss #1

Closed ChuangbinC closed 4 years ago

ChuangbinC commented 4 years ago

Hi, @jzengust You use a hybrid loss function which contain L1 loss and L2 loss to train the model. But I only see the L1 loss function in your code. Thanks.

jzengust commented 4 years ago

Hi @ChuangbinC

Thanks for the question. For normal estimation with RGB input, we use L1 only for training. While for RGBD fusion network, we use L1 for the first 5-10 epoch, then use the hybrid loss for the next 5-10 epoch. Please kindly refer to the training details in README. Thank you very much.

Best regards, Jin

ChuangbinC commented 4 years ago

Thanks for your reply. @jzengust Maybe what I said is not clear. I want to ask why you use cosine loss instead of L2 loss in hybrid loss function in your code. The hybrid loss function contains L1 loss and L2 loss in your paper.

Thanks.

jzengust commented 4 years ago

@ChuangbinC Yes, the hybrid loss is a linear combination of L1 and L2. In the training script, the loss is named "cosine", but "cosine" and L2 are equivalent given that the L2 norm of the normal vectors is constant after normalization.

Best, Jin

ChuangbinC commented 4 years ago

@jzengust I know "cosine" can measure the similarity between two normal vectors but I don't understand that what is mean? Could you please give me an example? but "cosine" and L2 are equivalent given that the L2 norm of the normal vectors is constant after normalization. Thanks.

jzengust commented 4 years ago

@ChuangbinC For example, given two normal vectors, v1 and v2 L2 loss = ||v1-v2||^2 = ||v1||^2 + ||v2||^2 - 2dot product(v1, v2) = ||v1||^2 + ||v2||^2 - 2 ||v1||||v2||*cos(v1, v2) given ||v1||=||v2||=1 after normalization, the above equation = 2-2cos(v1,v2), which is exactly the same as the "cosine" loss we use in the script.

Hope this answers your question.

Best, Jin

ChuangbinC commented 4 years ago

@jzengust Thanks for your reply. It helps me a lot.