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

fix: Don't crash NLL classifier if all targets are unlabeled #2620

Merged
merged 1 commit into from Aug 24, 2018

Conversation

griffinkardos
Copy link

What changes were proposed in this pull request?

If all the targets are unlabeled (or all target classes have a weight of zero), changes total_weight from 0 to 1, so it doesn't crash in backwards() when it asserts the total weight is > 0. This doesn't change the output of forward or backwards to anything unexpected.

Related links or issues (optional)

fixed #2617

@@ -153,6 +153,9 @@ class ClassNLLCriterion[@specialized(Float, Double) T: ClassTag]
total_weight = ev.plus(total_weight, w)
i += 1
}
if(total_weight == 0){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a style check failure.

StyleCheck/spark/dl/src/main/scala/com/intel/analytics/bigdl/nn/ClassNLLCriterion.scala message=
      Single Space between ')' and `{`.
     line=156 column=26

@yiheng
Copy link
Contributor

yiheng commented Aug 23, 2018

Thanks for the contribution. Only a small issue. The Jenkins job failed at style check. Please check my comments.

@griffinkardos
Copy link
Author

Okay thanks. I amended that

@yiheng
Copy link
Contributor

yiheng commented Aug 24, 2018

jenkins pass

@yiheng yiheng merged commit 39882fa into intel-analytics:master Aug 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants