def load_attack(self):
        """
        load attack.
        """

        self.attack_class = utils.get_class('attacks', self.args.attack)
        if not self.attack_class:
            log('[Error] could not find attack %s' % self.args.attack, LogLevel.ERROR)
            exit(1)
        log('[Training] found %s' % self.attack_class)
        # attack is instantiated per sample

        if self.args.attack.lower().find('l1') > 0:
            self.norm = 1
        elif self.args.attack.lower().find('l2') > 0:
            self.norm = 2
        elif self.args.attack.lower().find('linf') > 0:
            self.norm = float('inf')
        else:
            raise NotImplementedError('could not determine norm from attack name')

        self.objective_class = utils.get_class('attacks', self.args.objective)
        if not self.objective_class:
            log('[Error] could not find objective %s' % self.args.objective, LogLevel.ERROR)
            exit(1)
        log('[Training] found %s' % self.objective_class)
    def load_attack(self):
        """
        Load attack and objective:
        """

        self.attack_class = utils.get_class('attacks', self.args.attack)
        if not self.attack_class:
            log('[Error] could not find attack %s' % self.args.attack, LogLevel.ERROR)
            exit(1)
        log('[Attack] found %s' % self.attack_class)
        # attack is instantiated per sample

        self.objective_class = utils.get_class('attacks', self.args.objective)
        if not self.objective_class:
            log('[Error] could not find objective %s' % self.args.objective, LogLevel.ERROR)
            exit(1)
        log('[Attack] found %s' % self.objective_class)
Esempio n. 3
0
    def load_attack(self):
        """
        Load attack and objective:
        """

        self.objective_class = utils.get_class('attacks', self.args.objective)
        if not self.objective_class:
            log('[Error] could not find objective %s' % self.args.objective,
                LogLevel.ERROR)
            exit(1)
        log('[Visualization] found %s' % self.objective_class)
Esempio n. 4
0
 def get_importer(self):
     importer_class = get_class(self.importer.module)
     return importer_class(self)