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

fixed apply_mask bug in losses #802

Merged
merged 4 commits into from
Aug 28, 2023
Merged

Conversation

jackd
Copy link
Contributor

@jackd jackd commented Aug 27, 2023

This fix ensures that losses evaluated with a sample_weights == ops.cast(mask, "float32") are the same as those evaluated with either argument but not both None. Note this total is consistent with the batch_size used in reduce_values, corresponding to the total size of all elements as opposed to the leading dimension. Another fix might be to leave apply_mask alone and change reduce_values to divide by the leading dimension only rather than the total size.

I'm unsure of a concise way to unit test this because AFAIK there's no way to pass a mask in using only the public API...

Copy link
Contributor

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

Thanks for the fix -- please add a unit test for this case.

Copy link
Contributor

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

LGTM, thank you! 👍

@fchollet fchollet merged commit aea55a9 into keras-team:main Aug 28, 2023
@jackd jackd deleted the apply-mask-fix branch September 7, 2023 02:17
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

Successfully merging this pull request may close these issues.

2 participants