-
-
Notifications
You must be signed in to change notification settings - Fork 45.6k
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
Fixed: #12233 #12249
Fixed: #12233 #12249
Conversation
|
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.
[Invalid] Its already being PR
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.
Please see my comment in the conversation
Note that y_true is an array so comparing it to 0 might not be a good idea here, and there are nonzero entries that should be calculated instead of just returning 0.
This causes
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
@anandfresh I do not think the PR should be approved as it is not correct and do not resolve what the issue intends. |
@kevin1kevin1k - Yes, my bad ! I didn't see it is an array variable . Ideally he has to check if the array length is greater than 0 |
@@ -659,7 +659,10 @@ def kullback_leibler_divergence(y_true: np.ndarray, y_pred: np.ndarray) -> float | |||
if len(y_true) != len(y_pred): | |||
raise ValueError("Input arrays must have the same length.") | |||
|
|||
kl_loss = y_true * np.log(y_true / y_pred) | |||
kl_loss = 0 | |||
if y_true != 0: |
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.
Shouldn't you check the length of the y_true
array greater than 0?
Closing tests_are_failing PRs to prepare for Hacktoberfest |
I have added a logic that restricts the evaluation of log function if y_true is 0.
Checklist: