File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
art/attacks/evasion/imperceptible_asr Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff 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 ]
You can’t perform that action at this time.
0 commit comments