Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question on the Loss function #3

Open
simo23 opened this issue Sep 5, 2017 · 2 comments
Open

Question on the Loss function #3

simo23 opened this issue Sep 5, 2017 · 2 comments

Comments

@simo23
Copy link

simo23 commented Sep 5, 2017

Hi, thanks for your very useful code!

I want to ask you something about the loss function, because I've seen it implemented in many ways but this seems the best one:

  • Is it correct to compute a single mask for an entire batch and compute the loss on it? This should be the wrong way because many objects could be in the same cell, so we will have overlapping. I'm quite sure this is not the way it is implemented here.

  • Is it correct to compute the mask for each single image and then compute the loss as the average on the batch, like:

    total_loss = 1/N sum_for_every_image(image_loss)
    

This is the way it is implemented here I think, but can you confirm this? Unfortunately it is not clear how to compute it exactly.

Also can you explain the following line found in "yolo_v2_confidence_loss"?

  object_no_detections = tf.cast(iou < 0.6, tf.float32) 
  objects_loss = object_scale * object_mask * object_no_detections * tf.square(1 - box_confidence)

I imagine you are thresholding the iou between the ground truth boxes and the predictions, but can you explain this choice? Are you saying that even if the box is in the right cell it must have iou > 0.6 w.r.t. ground truth to be counted in this loss?

Lastly, are you planning to add the possibility to load pre-trained weights? It will be useful and if you want I could also help.

Thanks, Andrea

@PaulChongPeng
Copy link
Owner

  1. total_loss = 1/N sum_for_every_image(image_loss)
  2. If the IOU between prediction box and ground truth box is biger than 0.6, I think it's a right cell. Otherwise, it contribute to the object loss.

@simo23
Copy link
Author

simo23 commented Nov 7, 2017

Hi,
thanks for your answer. I have another question tough.

By applying that any box with iou > 0.6 with a ground_truth box is correct you are basically justifying all detectors (of any cell, and any anchor) to go to objects they are not necessarily responsible for am I right?

Would it be a more correct way to find the cell in which the ground truth box has the center, than select in that cell the anchor with the best iou with the ground truth box and then keep a single 1 in the loss mask ( in the right cell, at the right anchor ) for each ground truth object?

Thanks,
Andrea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants