MCPcopy Create free account
hub / github.com/HobbitLong/SupContrast / __init__

Method __init__

losses.py:14–19  ·  view source on GitHub ↗
(self, temperature=0.07, contrast_mode='all',
                 base_temperature=0.07)

Source from the content-addressed store, hash-verified

12 """Supervised Contrastive Learning: https://arxiv.org/pdf/2004.11362.pdf.
13 It also supports the unsupervised contrastive loss in SimCLR"""
14 def __init__(self, temperature=0.07, contrast_mode='all',
15 base_temperature=0.07):
16 super(SupConLoss, self).__init__()
17 self.temperature = temperature
18 self.contrast_mode = contrast_mode
19 self.base_temperature = base_temperature
20
21 def forward(self, features, labels=None, mask=None):
22 """Compute loss for model. If both `labels` and `mask` are None,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected