From 13a7e646e82e51942ad91ce2d301770bca96c8c2 Mon Sep 17 00:00:00 2001 From: Thalles Silva Date: Thu, 21 Jan 2021 06:32:08 -0300 Subject: [PATCH] fix loss function labels --- run.py | 2 +- simclr.py | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/run.py b/run.py index 5b391ea..de3b0eb 100644 --- a/run.py +++ b/run.py @@ -54,7 +54,7 @@ parser.add_argument('--gpu-index', default=0, type=int, help='Gpu index.') def main(): args = parser.parse_args() - + assert args.n_views == 2, "Only two view training is supported." # check if gpu training is available if not args.disable_cuda and torch.cuda.is_available(): args.device = torch.device('cuda') diff --git a/simclr.py b/simclr.py index 5bd0e41..90a2707 100644 --- a/simclr.py +++ b/simclr.py @@ -55,9 +55,6 @@ class SimCLR(object): # select and combine multiple positives positives = similarity_matrix[labels.bool()].view(labels.shape[0], -1) - # if there is more than one potive (n_views >= 2) combine the multiple positives - positives = positives.mean(dim=1).unsqueeze(1) - # select only the negatives the negatives negatives = similarity_matrix[~labels.bool()].view(similarity_matrix.shape[0], -1)