Skip to content

Commit

Permalink
Merge pull request #2461 from Trusted-AI/dev_1.18.1
Browse files Browse the repository at this point in the history
Update to ART 1.18.1
  • Loading branch information
beat-buesser authored Jul 3, 2024
2 parents a20c78f + 7044477 commit 4508b6e
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,13 @@ def _projection(
if (suboptimal or norm == 2) and norm != np.inf: # Simple rescaling
values_norm = torch.linalg.norm(values_tmp, ord=norm, dim=1, keepdim=True) # (n_samples, 1)
values_tmp = values_tmp * values_norm.where(
values_norm == 0, torch.minimum(torch.ones(1), torch.Tensor(eps) / values_norm)
values_norm == 0, torch.minimum(torch.ones(1), torch.tensor(eps).to(values_tmp.device) / values_norm)
)
else: # Optimal
if norm == np.inf: # Easy exact case
values_tmp = values_tmp.sign() * torch.minimum(values_tmp.abs(), torch.Tensor(eps))
values_tmp = values_tmp.sign() * torch.minimum(
values_tmp.abs(), torch.tensor(eps).to(values_tmp.device)
)
elif norm >= 1: # Convex optim
raise NotImplementedError(
"Finite values of `norm_p >= 1` are currently not supported with `suboptimal=False`."
Expand Down

0 comments on commit 4508b6e

Please sign in to comment.