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

Add divergence metrics #3232

Merged
merged 8 commits into from
Apr 17, 2024
Merged

Add divergence metrics #3232

merged 8 commits into from
Apr 17, 2024

Conversation

kzkadc
Copy link
Contributor

@kzkadc kzkadc commented Apr 13, 2024

Description: added KL and JS divergences between two categorical predictions

Check list:

  • New tests are added (if a new feature is added)
  • New doc strings: description and/or example code are in RST format
  • Documentation is updated (if required)

@github-actions github-actions bot added docs module: metrics Metrics module labels Apr 13, 2024
kzkadc and others added 3 commits April 14, 2024 23:28
Co-authored-by: vfdev <vfdev.5@gmail.com>
Co-authored-by: vfdev <vfdev.5@gmail.com>
Copy link
Collaborator

@vfdev-5 vfdev-5 left a comment

Choose a reason for hiding this comment

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

Thanks a lot adding new metrics @kzkadc !

@vfdev-5 vfdev-5 enabled auto-merge (squash) April 17, 2024 13:58
@vfdev-5 vfdev-5 merged commit f431e60 into pytorch:master Apr 17, 2024
18 of 20 checks passed
@vfdev-5
Copy link
Collaborator

vfdev-5 commented Apr 18, 2024

@kzkadc can you please check this failure with pytorch 1.5.1: https://github.com/pytorch/ignite/actions/runs/8730344048/job/23953994151

TypeError: kl_div() got an unexpected keyword argument 'log_target'

Looks like log_target arg was not added in 1.5.1, can you see what would be the effort to support 1.5.1.
We have two options: a) fix ignite code if this is a minimal fix, b) drop support for 1.5.1 in our pytorch versions tests and replace it with a minimal later version. Option a) would be preferable but the fix should not be a large update of the code.

@kzkadc
Copy link
Contributor Author

kzkadc commented Apr 18, 2024

Thanks. The kl_div's behaviour in 1.5.1 is equivalent to log_target=False (default) in the current version.
We can fix it by passing the target variable to kl_div as a probabilities.

@vfdev-5
Copy link
Collaborator

vfdev-5 commented Apr 18, 2024

we can also make a small if-else depending on pytorch version. For example:

if Version(torch.__version__) <= Version("1.7.0"):

Using log_target may be has better computation result stability (to confirm), so, for recent pytorch it would be better to use this option if it makes more sense to use vs keeping default log_target=False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants