Skip to content

Commit 263c532

Browse files
authored
Merge branch 'dev_1.11.1' into random-sphere-clean
2 parents 51eab55 + 1ecd3b5 commit 263c532

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

art/attacks/evasion/adversarial_patch/adversarial_patch.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,6 @@ def generate( # type: ignore
164164
"""
165165
logger.info("Creating adversarial patch.")
166166

167-
if y is None: # pragma: no cover
168-
raise ValueError("Adversarial Patch attack requires target values `y`.")
169-
170167
if len(x.shape) == 2: # pragma: no cover
171168
raise ValueError(
172169
"Feature vectors detected. The adversarial patch can only be applied to data with spatial "

art/attacks/evasion/adversarial_patch/adversarial_patch_pytorch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,13 +682,13 @@ def apply_patch(
682682
if mask is not None:
683683
mask = mask.copy()
684684
mask = self._check_mask(mask=mask, x=x)
685-
x_tensor = torch.Tensor(x)
685+
x_tensor = torch.Tensor(x).to(self.estimator.device)
686686
if mask is not None:
687-
mask_tensor = torch.Tensor(mask)
687+
mask_tensor = torch.Tensor(mask).to(self.estimator.device)
688688
else:
689689
mask_tensor = None
690690
if isinstance(patch_external, np.ndarray):
691-
patch_tensor = torch.Tensor(patch_external)
691+
patch_tensor = torch.Tensor(patch_external).to(self.estimator.device)
692692
else:
693693
patch_tensor = self._patch
694694
return (

art/estimators/classification/pytorch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def predict( # pylint: disable=W0221
322322
output = model_outputs[-1]
323323
output = output.detach().cpu().numpy().astype(np.float32)
324324
if len(output.shape) == 1:
325-
output = np.expand_dims(output.detach().cpu().numpy(), axis=1).astype(np.float32)
325+
output = np.expand_dims(output, axis=1).astype(np.float32)
326326

327327
results_list.append(output)
328328

0 commit comments

Comments
 (0)