Skip to content

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