Closed shenyehui closed 9 months ago
Hi, thank you for your interest in our work!
Unfortunately, I'm not sure I understood your question very well. Could you elaborate on your question a bit? What is the difference between this with what we described in the paper (Eq.3 and 4)?
Hi, thank you for your interest in our work!
Unfortunately, I'm not sure I understood your question very well. Could you elaborate on your question a bit? What is the difference between this with what we described in the paper (Eq.3 and 4)?
I'm sorry for not making my question clear. What I want to ask is: in the paper, the inputs to Ltriplet are M^p_real, M^p_syn, M^(p^-)_real, M^(p^-)_syn. But in the code (loss_f = triplet_loss_hard_negative_mining_plus(features_rgb, features_target, margin=args.triplet_margin)), why are only M^p_real and M^p_syn used as inputs?
The negative samples are sampled by torch.roll() here. L410 and L412.
Then, in L417 to 422, we find negative pairs that have negative distance, referring to Equation 4.
Lastly, we select specific negative pairs with minimum negative distance into the triplet loss for that iteration.
Notice that the loss is designed to minimize the feature-metric distance between synthetic and real images with the same camera poses and maximize the distance between images with different camera poses.
- The negative samples are sampled by torch.roll() here. L410 and L412.
- Then, in L417 to 422, we find negative pairs that have negative distance, referring to Equation 4.
- Lastly, we select specific negative pairs with minimum negative distance into the triplet loss for that iteration.
Notice that the loss is designed to minimize the feature-metric distance between synthetic and real images with the same camera poses and maximize the distance between images with different camera poses.
Thank you for your answer. What I would like to ask is, in the code, are negative samples collected using torch.roll() representing images with different camera poses, rather than actually inputting images with different camera poses?
hi, yes that’s correct.
hi, yes that’s correct.
Thank you for your patient explanations. I will close this question.
Thank you for your great work. The Loss_triplet function I found in the code seems to differ from the one you described in the paper. Have you made any modifications to the loss in your code? Below is the Loss_triplet function from your code, and I look forward to your explanation!
def triplet_loss_hard_negative_mining_plus(f1, f2, margin=1.): ''' triplet loss with hard negative mining, four cases. inspired by http://www.bmva.org/bmvc/2016/papers/paper119/paper119.pdf section3.3 :param criterion: loss function :param f1: [lvl, B, C, H, W] :param f2: [lvl, B, C, H, W] :return: loss ''' criterion = nn.TripletMarginLoss(margin=margin, reduction='mean') anchor = f1 anchor_negative = torch.roll(f1, shifts=1, dims=1) positive = f2 negative = torch.roll(f2, shifts=1, dims=1)