@@ -118,23 +118,11 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
118118
119119 grid_trans_x = [
120120 int (round (g ))
121- for g in list (
122- np .linspace (
123- - max_num_pixel_trans_x ,
124- max_num_pixel_trans_x ,
125- num = self .num_translations ,
126- )
127- )
121+ for g in list (np .linspace (- max_num_pixel_trans_x , max_num_pixel_trans_x , num = self .num_translations ,))
128122 ]
129123 grid_trans_y = [
130124 int (round (g ))
131- for g in list (
132- np .linspace (
133- - max_num_pixel_trans_y ,
134- max_num_pixel_trans_y ,
135- num = self .num_translations ,
136- )
137- )
125+ for g in list (np .linspace (- max_num_pixel_trans_y , max_num_pixel_trans_y , num = self .num_translations ,))
138126 ]
139127 grid_rot = list (np .linspace (- self .max_rotation , self .max_rotation , num = self .num_rotations ))
140128
@@ -187,8 +175,7 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
187175 self .attack_rot = rot
188176
189177 logger .info (
190- "Success rate of spatial transformation attack: %.2f%%" ,
191- 100 * self .fooling_rate ,
178+ "Success rate of spatial transformation attack: %.2f%%" , 100 * self .fooling_rate ,
192179 )
193180 logger .info ("Attack-translation in x: %.2f%%" , self .attack_trans_x )
194181 logger .info ("Attack-translation in y: %.2f%%" , self .attack_trans_y )
@@ -211,10 +198,7 @@ def _perturb(self, x: np.ndarray, trans_x: int, trans_y: int, rot: float) -> np.
211198
212199 if self .estimator .clip_values is not None :
213200 np .clip (
214- x_adv ,
215- self .estimator .clip_values [0 ],
216- self .estimator .clip_values [1 ],
217- out = x_adv ,
201+ x_adv , self .estimator .clip_values [0 ], self .estimator .clip_values [1 ], out = x_adv ,
218202 )
219203
220204 return x_adv
0 commit comments