Skip to content

Commit c0da48c

Browse files
Update projected_gradient_descent_pytorch.py
Solve non-writable NumPy array and device mismatch issues. Signed-off-by: salomonhotegni <[email protected]>
1 parent a03c85e commit c0da48c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

art/attacks/evasion/projected_gradient_descent/projected_gradient_descent_pytorch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ def _projection(
501501
)
502502
else: # Optimal
503503
if norm == np.inf: # Easy exact case
504-
values_tmp = values_tmp.sign() * torch.minimum(values_tmp.abs(), torch.Tensor(eps))
504+
values_tmp = values_tmp.sign() * torch.minimum(values_tmp.abs(), torch.tensor(eps).to(values_tmp.device))
505505
elif norm >= 1: # Convex optim
506506
raise NotImplementedError(
507507
"Finite values of `norm_p >= 1` are currently not supported with `suboptimal=False`."

0 commit comments

Comments
 (0)