From c057471dd0d76f329e9bee9fce626a4f92990dae Mon Sep 17 00:00:00 2001 From: Thalles Silva Date: Sat, 18 Apr 2020 11:40:10 -0300 Subject: [PATCH] Update simclr.py --- simclr.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/simclr.py b/simclr.py index 9a58f94..7d3a29a 100644 --- a/simclr.py +++ b/simclr.py @@ -138,13 +138,14 @@ def _validate(self, model, valid_loader): model.eval() valid_loss = 0.0 - for counter, ((xis, xjs), _) in enumerate(valid_loader): + counter = 0 + for (xis, xjs), _ in valid_loader: xis = xis.to(self.device) xjs = xjs.to(self.device) loss = self._step(model, xis, xjs, counter) valid_loss += loss.item() - + counter += 1 valid_loss /= counter model.train() return valid_loss