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

5 implement mmd #22

Merged
merged 25 commits into from
Feb 10, 2023
Merged

5 implement mmd #22

merged 25 commits into from
Feb 10, 2023

Conversation

philswatton
Copy link
Contributor

@philswatton philswatton commented Feb 7, 2023

This PR implements the following:

  • mmd function which takes two NP arrays, an embedding name, and a kernel name as input
    • internal dicts are used to transform strings to embedding functions and kernel functions
    • this is for compatability with using configs
  • load_config to handle loading configs given a file path
    • atm it only loads a config for similarity metrics, but is set up for easy extension to e.g. dataset and experiment configs in the future
  • tests for both of these, which use their own config file

This resolves #5 and contributes to #19.

I've also opened two new issues to further extend this initial implementation:

  • MMD by class #20 suggests looking at implementing MMD by class (rather than MMD over the whole dataset) in the future, with arguments to handle this to be added to both config and mmd
  • Embeddings #21 suggests looking at using feature embeddings as an additional hyperparameter to the MDD

EDIT: I also added some CIFAR bits to the .gitignore as suggested by @jack89roberts at some point somewhere

Copy link
Contributor

@jack89roberts jack89roberts left a comment

Choose a reason for hiding this comment

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

Few initial comments whilst I wait for some things to run 🙂

Copy link
Contributor

@lannelin lannelin left a comment

Choose a reason for hiding this comment

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

Looking good so far! Some fairly minor changes requested in comments.

Copy link
Contributor

@lannelin lannelin left a comment

Choose a reason for hiding this comment

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

looks great, a couple of very minor comments then happy to merge without re-review.

Have run the following on my machine and returns a very small value for mmd (1.5625e-05) with rbf kernel. I imagine this is somewhat expected even with fairly large drop sizes?

from modsim2.data.loader import DMPair

metric_config = {'mmd_rbf': {'function': 'mmd', 'arguments': {'embedding_name': 'matrix', 'kernel_name': 'rbf'}}}

dmpair = DMPair(metric_config=metric_config, drop_percent_A=0.2, drop_percent_B=0.2)

dmpair.compute_similarity()

Copy link
Contributor

@jack89roberts jack89roberts left a comment

Choose a reason for hiding this comment

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

Added a minor formatting comment but LGTM. Re James' last comment - maybe a sanity check/test that mmd with drop=0.8 is greater than with drop=0.2 (for example), would be helpful just to convince that it is working as expected.

Co-authored-by: Jack Roberts <[email protected]>
@philswatton philswatton merged commit 6bbbef2 into develop Feb 10, 2023
@philswatton philswatton deleted the 5_implement_mmd branch February 10, 2023 10:12
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.

Implement Maximum Mean Discrepancy
3 participants