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

CategoricalCrossEntropy.get_grad: fix invariants check #587

Merged
merged 3 commits into from
Feb 16, 2022

Conversation

danieldk
Copy link
Contributor

@danieldk danieldk commented Feb 5, 2022

get_grad checked the guesses/target invariants as follows:

if guesses.any() > 1 or guesses.any() < 0:

However, guesses.any() only has two possible outputs, True or False,
which are reinterpreted as 1 or 0, so the condition is always false.

This change updates the conditions to actually check that guesses
and target are in [0, 1].

get_grad checked the guesses/target invariants as follows:

```
if guesses.any() > 1 or guesses.any() < 0:
```

However, `guesses.any()` only has two possible outputs, True or False,
which are reinterpreted as 1 or 0, so the condition is always false.

This change updates the conditions to actually check that guesses
and target are in [0, 1].
@danieldk danieldk added the bug Bugs and behaviour differing from documentation label Feb 5, 2022
Copy link
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

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

Could you add a test that failed to fail before this PR?

@svlandeg svlandeg added the feat / ops Backends and maths label Feb 11, 2022
@danieldk
Copy link
Contributor Author

Could you add a test that failed to fail before this PR?

Fixed!

Copy link
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

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

Great!

@svlandeg svlandeg merged commit 731816a into explosion:master Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs and behaviour differing from documentation feat / ops Backends and maths
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants