From eec72da9c1ebd87adf0a9f830d60f5c57d3d6a29 Mon Sep 17 00:00:00 2001 From: Nataniel Ruiz Date: Wed, 25 Dec 2019 20:42:07 -0400 Subject: [PATCH] next --- cyclegan/models/test_model.py | 5 ----- cyclegan/test.py | 7 ------- cyclegan/util/attacks.py | 4 +--- 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/cyclegan/models/test_model.py b/cyclegan/models/test_model.py index d7eaa8d..c71f708 100644 --- a/cyclegan/models/test_model.py +++ b/cyclegan/models/test_model.py @@ -78,8 +78,6 @@ class TestModel(BaseModel): black = np.zeros((1, 3, image.size(2), image.size(3))) black = torch.FloatTensor(black).cuda() input_adv, perturb = pgd_attack.perturb(image, black) - - black = None return input_adv, perturb @@ -94,9 +92,6 @@ class TestModel(BaseModel): l2 = F.mse_loss(generated, generated_noattack) l0 = (generated - generated_noattack).norm(0) d = (generated - generated_noattack).norm(float('-inf')) - - generated = None - generated_noattack = None return l1, l2, l0, d diff --git a/cyclegan/test.py b/cyclegan/test.py index 8ce44af..2e49a6e 100644 --- a/cyclegan/test.py +++ b/cyclegan/test.py @@ -85,13 +85,6 @@ if __name__ == '__main__': print('processing (%04d)-th image... %s' % (i, img_path)) save_images(webpage, visuals, img_path, aspect_ratio=opt.aspect_ratio, width=opt.display_winsize) - model.fake = None - model.real = None - model.fake_noattack = None - data = None - perturb = None - input_adv = None - webpage.save() # save the HTML diff --git a/cyclegan/util/attacks.py b/cyclegan/util/attacks.py index b6296ff..18b90cd 100644 --- a/cyclegan/util/attacks.py +++ b/cyclegan/util/attacks.py @@ -35,10 +35,8 @@ class LinfPGDAttack(object): eta = torch.clamp(X_adv - X_nat, min=-self.epsilon, max=self.epsilon) X = torch.clamp(X_nat + eta, min=-1, max=1).detach_() - eta = None - X_adv = None - return X, X - X_nat + return X, eta def clip_tensor(X, Y, Z): # Clip X with Y min and Z max