def config(self, **kwargs): ''' (Re)config the attack. :param magnitude: Max distortion, could be either a float number or a numpy float number array with shape of (batch_size,). :param alpha: Step size for each iteration, could be either a float number or a numpy float number array with shape of (batch_size,). :param iteration: Iteration count. An integer. ''' if 'magnitude' in kwargs: eps = maybe_to_array(kwargs['magnitude'], self.batch_size) self._session.run(self.config_eps_step, feed_dict={self.eps_ph: eps}) if 'alpha' in kwargs: alpha = maybe_to_array(kwargs['alpha'], self.batch_size) self._session.run(self.config_alpha_step, feed_dict={self.alpha_ph: alpha}) if 'iteration' in kwargs: self.iteration = kwargs['iteration']
def config(self, **kwargs): ''' (Re)config the attack. :param magnitude: Max distortion, could be either a float number or a numpy float number array with shape of `(self.batch_size,)`. ''' if 'magnitude' in kwargs: eps = maybe_to_array(kwargs['magnitude'], self.batch_size) self._session.run(self.config_eps_step, feed_dict={self.eps_ph: eps})
def config(self, **kwargs): ''' (Re)config the attack. :param magnitude: Max distortion, could be either a float number or a numpy float number array with shape of ``(self.batch_size,)``. :param alpha: Step size for each iteration, could be either a float number or a numpy float number array with shape of ``(self.batch_size,)``. :param decay_factor: A float number, the decay factor for momentum. :param iteration: An integer, the iteration count. ''' if 'magnitude' in kwargs: eps = maybe_to_array(kwargs['magnitude'], self.batch_size) self._session.run(self.config_eps_step, feed_dict={self.eps_ph: eps}) if 'alpha' in kwargs: alpha = maybe_to_array(kwargs['alpha'], self.batch_size) self._session.run(self.config_alpha_step, feed_dict={self.alpha_ph: alpha}) if 'decay_factor' in kwargs: decay_factor = kwargs['decay_factor'] self._session.run(self.config_decay_factor_step, feed_dict={self.decay_factor_ph: decay_factor}) if 'iteration' in kwargs: self.iteration = kwargs['iteration']
def config(self, **kwargs): ''' (Re)config the attack. :param rand_init_magnitude: Random init max distortion, could be either a float number or a numpy float number array with shape of `(self.batch_size,)`. :param magnitude: Max distortion, could be either a float number or a numpy float number array with shape of `(self.batch_size,)`. :param alpha: Step size for each iteration, could be either a float number or a numpy float number array with shape of `(self.batch_size,)`. :param iteration: Iteration count. An integer. ''' super().config(**kwargs) if 'rand_init_magnitude' in kwargs: rand_init_eps = maybe_to_array(kwargs['rand_init_magnitude'], self.batch_size) self._session.run(self.config_rand_init_eps, feed_dict={self.rand_init_eps_ph: rand_init_eps})
def config(self, **kwargs): ''' (Re)config the attack. :param cs: Initial c, could be either a float number or a numpy float number array with shape of `(self.batch_size,)`. :param iteration: An integer, represent iteration count for each search step and binary search step. :param search_steps: An integer, the number of times for running initial search for c before binary search. :param binsearch_steps: An integer, the number of times for running binary search on c. :param logger: A standard logger for logging verbose information during attacking. ''' if 'cs' in kwargs: self.cs = maybe_to_array(kwargs['cs'], target_len=self.batch_size).astype( self.model.x_dtype.as_numpy_dtype) if 'iteration' in kwargs: self.iteration = kwargs['iteration'] if 'search_steps' in kwargs: self.search_steps = kwargs['search_steps'] if 'binsearch_steps' in kwargs: self.binsearch_steps = kwargs['binsearch_steps'] if 'logger' in kwargs: self.logger = kwargs['logger']