コード例 #1
0
 def __init__(self, pgd_alpha: float = 1.0, pgd_epsilon: float = 8.0, pgd_iteration: int = 8,
              stop_conf: float = 0.9,
              magnet: bool = False, randomized_smooth: bool = False, curvature: bool = False, **kwargs):
     super().__init__(**kwargs)
     self.param_list['pgd'] = ['pgd_alpha', 'pgd_epsilon', 'pgd_iteration']
     self.pgd_alpha: float = pgd_alpha
     self.pgd_epsilon: float = pgd_epsilon
     self.pgd_iteration: int = pgd_iteration
     self.pgd = PGD_Optimizer(alpha=self.pgd_alpha / 255, epsilon=self.pgd_epsilon / 255,
                              iteration=self.pgd_iteration)
     self.stop_conf: float = stop_conf
     if magnet:
         self.magnet: MagNet = MagNet(dataset=self.dataset, pretrain=True)
     self.randomized_smooth: bool = randomized_smooth
     if curvature:
         self.curvature: Curvature = Curvature(model=self.model)
コード例 #2
0
ファイル: imc_poison.py プロジェクト: ain-soph/trojanzoo
 def __init__(self, pgd_alpha: float = 1.0, pgd_eps: float = 8.0, pgd_iter: int = 8,
              stop_conf: float = 0.9,
              magnet: bool = False, randomized_smooth: bool = False, curvature: bool = False, **kwargs):
     super().__init__(**kwargs)
     self.param_list['pgd'] = ['pgd_alpha', 'pgd_eps', 'pgd_iter']
     self.pgd_alpha: float = pgd_alpha
     self.pgd_eps: float = pgd_eps
     self.pgd_iter: int = pgd_iter
     self.pgd = PGDoptimizer(pgd_alpha=self.pgd_alpha / 255, pgd_eps=self.pgd_eps / 255,
                             iteration=self.pgd_iter)
     self.stop_conf: float = stop_conf
     if magnet:
         self.magnet: MagNet = MagNet(dataset=self.dataset, pretrained=True)
     self.randomized_smooth: bool = randomized_smooth
     if curvature:
         from trojanvision.defenses.adv.curvature import Curvature
         self.curvature = Curvature(model=self.model)
コード例 #3
0
ファイル: imc_magnet.py プロジェクト: hkunzhe/trojanzoo
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     self.magnet = MagNet(dataset=self.dataset, pretrain=True)