Skip to content

Commit 3d06512

Browse files
author
Beat Buesser
committed
Apply Black formatting
Signed-off-by: Beat Buesser <[email protected]>
1 parent 7e5ccb4 commit 3d06512

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

art/attacks/evasion/deepfool.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,8 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
120120

121121
# Compute perturbation with implicit batching
122122
for batch_id in trange(
123-
int(np.ceil(x_adv.shape[0] / float(self.batch_size))),
124-
desc="DeepFool",
125-
disable=not self.verbose):
123+
int(np.ceil(x_adv.shape[0] / float(self.batch_size))), desc="DeepFool", disable=not self.verbose
124+
):
126125
batch_index_1, batch_index_2 = batch_id * self.batch_size, (batch_id + 1) * self.batch_size
127126
batch = x_adv[batch_index_1:batch_index_2].copy()
128127

art/attacks/evasion/projected_gradient_descent/projected_gradient_descent_pytorch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def _apply_perturbation(self, x: "torch.Tensor", perturbation: "torch.Tensor", e
277277
clip_min, clip_max = self.estimator.clip_values
278278
x = torch.max(
279279
torch.min(x, torch.tensor(clip_max).to(self.estimator.device)),
280-
torch.tensor(clip_min).to(self.estimator.device)
280+
torch.tensor(clip_min).to(self.estimator.device),
281281
)
282282

283283
return x
@@ -328,7 +328,7 @@ def _compute_torch(
328328
clip_min, clip_max = self.estimator.clip_values
329329
x_adv = torch.max(
330330
torch.min(x_adv, torch.tensor(clip_max).to(self.estimator.device)),
331-
torch.tensor(clip_min).to(self.estimator.device)
331+
torch.tensor(clip_min).to(self.estimator.device),
332332
)
333333

334334
else:

art/defences/preprocessor/mp3_compression.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def wav_to_mp3(x, sample_rate):
120120
elif x.dtype != np.int16 and normalized:
121121
# x is not of type np.int16 and seems to be normalized. Therefore undoing normalization and
122122
# casting to np.int16.
123-
x = (x * 2**15).astype(np.int16)
123+
x = (x * 2 ** 15).astype(np.int16)
124124

125125
tmp_wav, tmp_mp3 = BytesIO(), BytesIO()
126126
write(tmp_wav, sample_rate, x)
@@ -134,7 +134,7 @@ def wav_to_mp3(x, sample_rate):
134134

135135
if normalized:
136136
# x was normalized. Therefore normalizing x_mp3.
137-
x_mp3 = x_mp3 * 2**-15
137+
x_mp3 = x_mp3 * 2 ** -15
138138
return x_mp3
139139

140140
if x.ndim != 3:

tests/attacks/test_wasserstein.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ def set_learning_phase(self):
472472
kernel_size=3,
473473
max_iter=1,
474474
conjugate_sinkhorn_max_iter=10,
475-
projected_sinkhorn_max_iter=10
475+
projected_sinkhorn_max_iter=10,
476476
)
477477

478478
x = np.random.normal(size=(1, 3, 33, 32))

0 commit comments

Comments
 (0)