Skip to content

Commit f8f24d1

Browse files
author
Beat Buesser
committed
Apply Black formatter
Signed-off-by: Beat Buesser <[email protected]>
1 parent 6cfbfd7 commit f8f24d1

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

art/attacks/evasion/imperceptible_asr/imperceptible_asr_pytorch.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,7 @@ def _forward_1st_stage(
451451

452452
# Transform data into the model input space
453453
inputs, targets, input_rates, target_sizes, batch_idx = self.estimator.preprocess_transform_model_input(
454-
x=masked_adv_input.to(self.estimator.device),
455-
y=original_output,
456-
real_lengths=real_lengths,
454+
x=masked_adv_input.to(self.estimator.device), y=original_output, real_lengths=real_lengths,
457455
)
458456

459457
# Compute real input sizes
@@ -593,10 +591,7 @@ class only supports targeted attack.
593591
return result
594592

595593
def _forward_2nd_stage(
596-
self,
597-
local_delta_rescale: "torch.Tensor",
598-
theta_batch: np.ndarray,
599-
original_max_psd_batch: np.ndarray,
594+
self, local_delta_rescale: "torch.Tensor", theta_batch: np.ndarray, original_max_psd_batch: np.ndarray,
600595
) -> "torch.Tensor":
601596
"""
602597
The forward pass of the second stage of the attack.

art/estimators/speech_recognition/pytorch_deep_speech.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,7 @@ def __init__(
258258
enabled = True
259259

260260
self._model, self._optimizer = amp.initialize(
261-
models=self._model,
262-
optimizers=self._optimizer,
263-
enabled=enabled,
264-
opt_level=opt_level,
265-
loss_scale=1.0,
261+
models=self._model, optimizers=self._optimizer, enabled=enabled, opt_level=opt_level, loss_scale=1.0,
266262
)
267263

268264
def predict(
@@ -521,10 +517,7 @@ def fit(self, x: np.ndarray, y: np.ndarray, batch_size: int = 128, nb_epochs: in
521517
self._optimizer.step()
522518

523519
def preprocess_transform_model_input(
524-
self,
525-
x: "torch.Tensor",
526-
y: np.ndarray,
527-
real_lengths: np.ndarray,
520+
self, x: "torch.Tensor", y: np.ndarray, real_lengths: np.ndarray,
528521
) -> Tuple["torch.Tensor", "torch.Tensor", "torch.Tensor", "torch.Tensor", List]:
529522
"""
530523
Apply preprocessing and then transform the user input space into the model input space. This function is used
@@ -555,11 +548,7 @@ def preprocess_transform_model_input(
555548

556549
# Transform the input space
557550
inputs, targets, input_rates, target_sizes, batch_idx = self._transform_model_input(
558-
x=x,
559-
y=y,
560-
compute_gradient=False,
561-
tensor_input=True,
562-
real_lengths=real_lengths,
551+
x=x, y=y, compute_gradient=False, tensor_input=True, real_lengths=real_lengths,
563552
)
564553

565554
return inputs, targets, input_rates, target_sizes, batch_idx

0 commit comments

Comments
 (0)