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

Added MACL(Model Aware Contrastive learning ) Loss Function #1757

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Abhishekjha3515
Copy link

Added MACL(Model Aware Contrastive learning ) Loss Function in Loss folder

@Abhishekjha3515 Abhishekjha3515 changed the title Add files via upload Added MACL(Model Aware Contrastive learning ) Loss Function Dec 25, 2024
Copy link
Contributor

@guarin guarin left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution and sorry for the late review!

Could you add a minimal test in tests/loss/test_macl_loss.py? It is enough to pass some dummy values and check that the loss returns a valid value.

Could you also import the loss in lightly/loss/__init__.py? See https://github.com/lightly-ai/lightly/blob/master/lightly/loss/__init__.py, then it can be directly accessed as form lightly.loss import MACLLoss

Comment on lines +6 to +10
def __init__(self, temperature=0.1, alpha=0.5, A_0=0):
super().__init__()
self.t_0 = temperature
self.alpha = alpha
self.A_0 = A_0
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def __init__(self, temperature=0.1, alpha=0.5, A_0=0):
super().__init__()
self.t_0 = temperature
self.alpha = alpha
self.A_0 = A_0
def __init__(self, temperature: float = 0.1, alpha: float = 0.5, A_0: float = 0):
super().__init__()
self.temperature = temperature
self.alpha = alpha
self.A_0 = A_0

Could you also add a short docstring that describes what the loss does, what the parameters are, and add a reference to the paper that introduced the loss? You can follow the example here:

class NTXentLoss(nn.Module):

Copy link
Author

Choose a reason for hiding this comment

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

ok i will add the loss doc also

lightly/loss/macl_loss.py Outdated Show resolved Hide resolved
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