Skip to content

Added MMD #31

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Added MMD #31

wants to merge 5 commits into from

Conversation

Negiiiin
Copy link
Collaborator

@Negiiiin Negiiiin commented Jan 15, 2025

PR Type

[Feature ]

Short Description

Added MMD


This change is Reviewable

@Negiiiin Negiiiin requested a review from afkanpour January 15, 2025 22:19
Copy link
Collaborator

@afkanpour afkanpour left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 0 of 1 files reviewed, 7 unresolved discussions (waiting on @Negiiiin)


openpmcvl/statistical_analysis/MMD.py line 10 at r1 (raw file):

    From https://www.onurtunali.com/ml/2019/03/08/maximum-mean-discrepancy-in-machine-learning.html#formal-definition
"""
def MMD(x, y, kernel):

I believe the guideline says to use lowercase letters for function names.


openpmcvl/statistical_analysis/MMD.py line 15 at r1 (raw file):

    Args:
        x: first sample, distribution P

Please specify dimension of x and y in the docstring.


openpmcvl/statistical_analysis/MMD.py line 19 at r1 (raw file):

        kernel: kernel type such as "multiscale" or "rbf"
    """
    xx, yy, zz = torch.mm(x, x.t()), torch.mm(y, y.t()), torch.mm(x, y.t())

How about xy instead of zz since it is x y^T?

Code quote:

zz

openpmcvl/statistical_analysis/MMD.py line 23 at r1 (raw file):

    ry = (yy.diag().unsqueeze(0).expand_as(yy))

    dxx = rx.t() + rx - 2. * xx # Used for A in (1)

What is "(1)"?


openpmcvl/statistical_analysis/MMD.py line 23 at r1 (raw file):

    ry = (yy.diag().unsqueeze(0).expand_as(yy))

    dxx = rx.t() + rx - 2. * xx # Used for A in (1)

Please update these comments and indicate what intermediate quantities are calculated here.

Code quote:

# Used for A in (1)

openpmcvl/statistical_analysis/MMD.py line 27 at r1 (raw file):

    dxy = rx.t() + ry - 2. * zz # Used for C in (1)

    XX, YY, XY = (torch.zeros(xx.shape).to(device),

Please use lowercase variable names everywhere.


openpmcvl/statistical_analysis/MMD.py line 54 at r1 (raw file):

    """
    Loads all .pt files in a directory and combines them into a matrix.
    

Please remove all instances of trailing whitespaces.

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