This commit is contained in:
Nataniel Ruiz
2019-12-26 10:09:10 -04:00
parent 154b42d425
commit 4161e50d0e
2 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ import torch
import torch.nn as nn
class LinfPGDAttack(object):
def __init__(self, model=None, device=None, epsilon=0.05, k=20, a=0.01, feat = None):
def __init__(self, model=None, device=None, epsilon=0.05, k=1, a=0.05, feat = None):
self.model = model
self.epsilon = epsilon
self.k = k
+5 -5
View File
@@ -569,7 +569,7 @@ class Solver(object):
save_image(self.denorm(x_concat.data.cpu()), result_path, nrow=1, padding=0)
print('Saved real and fake images into {}...'.format(result_path))
def test_attack_output(self):
def test_attack(self):
"""Translate images using StarGAN trained on a single dataset."""
layer_dict = {0: 2, 1: 5, 2: 8, 3: 9, 4: 10, 5: 11, 6: 12, 7: 13, 8: 14, 9: 17, 10: 20, 11: None}
@@ -595,10 +595,10 @@ class Solver(object):
for i, (x_real, c_org) in enumerate(data_loader):
# Black image
# black = np.zeros((1,3,256,256))
# black = torch.FloatTensor(black).to(self.device)
black = np.zeros((1,3,256,256))
black = torch.FloatTensor(black).to(self.device)
black = torch.FloatTensor(torch.rand((1,3,256,256))).to(self.device)
# black = torch.FloatTensor(torch.rand((1,3,256,256))).to(self.device)
# Prepare input images and target domain labels.
x_real = x_real.to(self.device)
@@ -658,7 +658,7 @@ class Solver(object):
print('{} images. L1 error: {}. L2 error: {}. L0 error: {}. L_-inf error: {}. Perceptual error: {}.'.format(n_samples,
l1_error / n_samples, l2_error / n_samples, l0_error / n_samples, min_dist / n_samples, perceptual_error / n_samples))
def test_attack(self):
def test_attack_feats(self):
"""Translate images using StarGAN trained on a single dataset."""
layer_dict = {0: 2, 1: 5, 2: 8, 3: 9, 4: 10, 5: 11, 6: 12, 7: 13, 8: 14, 9: 17, 10: 20, 11: None}