Fix bug in loss for trees with one edge from leave to parent#5
Open
baumgach wants to merge 1 commit intofiveai:masterfrom
Open
Fix bug in loss for trees with one edge from leave to parent#5baumgach wants to merge 1 commit intofiveai:masterfrom
baumgach wants to merge 1 commit intofiveai:masterfrom
Conversation
|
Thanks and good catch! Yes your bug fix makes sense... but it seems you have Happy to merge when it is fixed :-) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi there, thanks for making the code for this project public!
I think there may be a bug in the calculation of the hierarchical cross-entropy loss for the edge case of having only one edge between leaf and parent. Specifically, on this line https://github.com/fiveai/making-better-mistakes/blob/master/better_mistakes/model/losses.py#L77,
j+1is used to fill in the last column. However, whenlen(edges_from_leaf[i])is 1, the loop for the denominator is never entered, soj=0, soonehot_den_np[i, :, 1] = 1.0. However, since there is only one leave, actually it should beonehot_den_np[i, :, 0] = 1.0.The bug can be fixed by changing line 77 to this:
This should work in every case. Let me know if you agree with me.