Skip to content

Commit cb95baf

Browse files
authored
Merge pull request #1677 from davidslater/imperceptible-asr-bug-detach
Imperceptible asr bug detach
2 parents 1fd1f92 + b3b8cf9 commit cb95baf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

art/attacks/evasion/imperceptible_asr/imperceptible_asr_pytorch.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ class only supports targeted attack.
409409
for local_batch_size_idx in range(local_batch_size):
410410
if decoded_output[local_batch_size_idx] == y[local_batch_size_idx]:
411411
# Adjust the rescale coefficient
412-
max_local_delta = np.max(np.abs(local_delta[local_batch_size_idx].detach().numpy()))
412+
max_local_delta = np.max(np.abs(local_delta[local_batch_size_idx].detach().cpu().numpy()))
413413

414414
if rescale[local_batch_size_idx][0] * self.eps > max_local_delta:
415415
rescale[local_batch_size_idx] = max_local_delta / self.eps
@@ -564,7 +564,9 @@ class only supports targeted attack.
564564
if decoded_output[local_batch_size_idx] == y[local_batch_size_idx]:
565565
if loss_2nd_stage[local_batch_size_idx] < best_loss_2nd_stage[local_batch_size_idx]:
566566
# Update best loss at 2nd stage
567-
best_loss_2nd_stage[local_batch_size_idx] = loss_2nd_stage[local_batch_size_idx].numpy()
567+
best_loss_2nd_stage[local_batch_size_idx] = (
568+
loss_2nd_stage[local_batch_size_idx].detach().cpu().numpy()
569+
)
568570

569571
# Save the best adversarial example
570572
successful_adv_input[local_batch_size_idx] = masked_adv_input[local_batch_size_idx]

0 commit comments

Comments
 (0)