MCPcopy Create free account
hub / github.com/TPCD/DCCL / ContrastiveLearningViewGenerator

Class ContrastiveLearningViewGenerator

project_utils/contrastive_utils.py:155–163  ·  view source on GitHub ↗

Take two random crops of one image as the query and key.

Source from the content-addressed store, hash-verified

153
154
155class ContrastiveLearningViewGenerator(object):
156 """Take two random crops of one image as the query and key."""
157
158 def __init__(self, base_transform, n_views=2):
159 self.base_transform = base_transform
160 self.n_views = n_views
161
162 def __call__(self, x):
163 return [self.base_transform(x) for i in range(self.n_views)]
164
165
166class SupConLoss(torch.nn.Module):

Callers 1

G0_CUB200.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected