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

Problem on Loss Function [division by zero] #35

Open
ahkarami opened this issue Jul 7, 2018 · 4 comments
Open

Problem on Loss Function [division by zero] #35

ahkarami opened this issue Jul 7, 2018 · 4 comments

Comments

@ahkarami
Copy link

ahkarami commented Jul 7, 2018

Dear @kuangliu,
In some Cases (on the training process) the num_pos will be equal to 0 (in the ssd_loss.py script).
Then an error will be occurred. So to address the issue, I have added the below code:

		...
        if num_pos > 0:
            print('loc_loss: %.3f | cls_loss: %.3f' % (loc_loss.item()/num_pos, cls_loss.item()/num_pos), end=' | ')
            loss = (loc_loss+cls_loss)/num_pos
        else:
            print('Number of Positive Samples is 0.')
            loss = (loc_loss+cls_loss)  # (??? I don't know correct or not)
        return loss

My question is that, in this situations the loss must be equal to zero (as the main paper of SSD mentioned) or a big number?
Related Links for above issue:
1- #16
2- GluonCV-Advanced Notes about SSD Training

@vaishnavm217
Copy link

OK I had the same problem, didn't think of setting it to zero, I had set N to 1, but that clearly seems the error. SSD paper has made it clear I think.

@vaishnavm217
Copy link

Moreover Assigning zero loss, it is not able to backpropagate.

@ahkarami
Copy link
Author

ahkarami commented Jul 8, 2018

@vaishnavm217,
I agree with you there.

@getsanjeev
Copy link

@ahkarami @vaishnavm217 what solution works for this?

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

3 participants