This commit is contained in:
Nataniel Ruiz
2019-12-25 20:42:07 -04:00
parent b35cda16cb
commit eec72da9c1
3 changed files with 1 additions and 15 deletions
-5
View File
@@ -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
-7
View File
@@ -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
+1 -3
View File
@@ -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