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 improved goodness of fit implementation #190

Merged
merged 14 commits into from
Feb 2, 2025

Conversation

stes
Copy link
Member

@stes stes commented Oct 27, 2024

This adds a better goodness of fit measure. Instead of the old variant which simply matched the InfoNCE and depends on the batch size, the proposed measure

  • is at 0 for "chance level" (vs. log batch size)
  • does not need an adjustment for single session vs. multi-session solvers
  • increases as the model gets better, which might be more intuitive

The conversion is quite simply done via

GoF(model) = log (batch_size_per_session * num_sessions) - InfoNCE(model)

This measure is also used in DeWolf et al., 2024, Eq. (43)

image

Application example (GoF improves from 0 to a larger value during training):

image

OLD example, for comparison

image


Close https://github.com/AdaptiveMotorControlLab/CEBRA-dev/pull/669

@cla-bot cla-bot bot added the CLA signed label Oct 27, 2024
@stes stes self-assigned this Oct 27, 2024
@stes stes mentioned this pull request Oct 27, 2024
16 tasks
@stes
Copy link
Member Author

stes commented Oct 27, 2024

TODO: Fix case where batch_size is None
image

@stes stes force-pushed the stes/better-goodness-of-fit branch from 5e21cdc to c826b68 Compare October 27, 2024 21:31
@stes stes mentioned this pull request Nov 29, 2024
@stes stes force-pushed the stes/better-goodness-of-fit branch from c826b68 to f43971f Compare November 29, 2024 13:31
@CeliaBenquet
Copy link
Member

@stes about what I implemented in #202 that I do see here.

I think it would be good to have a really basic function where you provide the loss and the batch size, so that it is easily usable in the pytorch implementation as well.

Also, it would be nice to test for the default CEBRA.batch_size = None, not sure it is handled here.

@stes
Copy link
Member Author

stes commented Dec 16, 2024

Unrelated build issue due to upstream change in sklearn (#204 ), attempted fix in #205

@stes stes requested a review from CeliaBenquet December 16, 2024 18:18
@stes
Copy link
Member Author

stes commented Dec 16, 2024

The build issue is fixed, and once #205 is merged tests should pass here as well.

@stes stes force-pushed the stes/better-goodness-of-fit branch from 1d55ead to ad8ae60 Compare December 16, 2024 19:33
@stes stes changed the title [WIP] Add improved goodness of fit implementation Add improved goodness of fit implementation Dec 16, 2024
@stes stes added the enhancement New feature or request label Dec 16, 2024
Copy link
Member

@CeliaBenquet CeliaBenquet left a comment

Choose a reason for hiding this comment

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

Thank you @stes! This looks nice!! Some minor suggestions on the docstrings and maybe add some tests for the different corner cases based on the arguments provided in infonce_to_goodness_of_fit.

@stes stes force-pushed the stes/better-goodness-of-fit branch from a1b4cf3 to f5ec82c Compare January 21, 2025 23:13
@stes
Copy link
Member Author

stes commented Jan 25, 2025

one review comment to resolve (= add more relevant tests for one batchsize None), then ready!

@stes stes force-pushed the stes/better-goodness-of-fit branch from 7c85975 to c94f5ae Compare January 25, 2025 16:27
@stes stes requested a review from CeliaBenquet January 25, 2025 16:27
@stes stes force-pushed the stes/better-goodness-of-fit branch from 0598346 to 3771990 Compare February 2, 2025 16:18
@stes stes requested review from MMathisLab and removed request for CeliaBenquet February 2, 2025 16:54
Copy link
Member

@MMathisLab MMathisLab left a comment

Choose a reason for hiding this comment

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

lgtm! thanks

@MMathisLab MMathisLab merged commit 4e32661 into main Feb 2, 2025
14 checks passed
@MMathisLab MMathisLab deleted the stes/better-goodness-of-fit branch February 2, 2025 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA signed enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants