-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Add pos_weight for binary_crossentropy_logits #10855
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
Add pos_weight for binary_crossentropy_logits #10855
Conversation
Changes |
| return (self.maximum(0) - Y * self + (1 + self.abs().neg().exp()).log())._do_reduction(reduction) | ||
| log_exp = (1 + self.abs().neg().exp()).log() | ||
| base = self.maximum(0) - Y * self | ||
| if pos_weight is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can pos_weight be integrated so that there's only one return code path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedbacks. Can you elaborate a bit more what did you mean by that? Do you have an existing example in tinygrad doing so I can refer to?
Also, any rationale for doing so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it a bit, assuming that pos_weight is not provied, it's actually just [1, 1, 1, ...], i.e, all weights for the ration between positive and negative case is just one. If my understanding of what you want correctly, you want to have a pos_weight tensor as part of the UOps graph regardless if it's provided as an argument or not. Is that understanding correct? If so, yeah, I can make it so. Please let me know 🙏
As for rationale, I am not expert in terms of Tinygrad's compiler, but I guess doing so would make it much easier to optimize?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't like if when it's not needed. unnecessary condition is hard to test well and maintain
03213a8 to
1318a2d
Compare
No description provided.