Skip to content

Commit d8256ec

Browse files
authored
Merge pull request #1762 from Trusted-AI/development_maintenance_111
Maintenance updates for ART 1.11.0
2 parents f4980b5 + 6370ab2 commit d8256ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+152
-104
lines changed

art/attacks/evasion/auto_attack.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
159159
"""
160160
x_adv = x.astype(ART_NUMPY_DTYPE)
161161
if y is not None:
162-
y = check_and_transform_label_format(y, self.estimator.nb_classes)
162+
y = check_and_transform_label_format(y, nb_classes=self.estimator.nb_classes)
163163

164164
if y is None:
165165
y = get_labels_np_array(self.estimator.predict(x, batch_size=self.batch_size))
@@ -207,7 +207,9 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
207207
if np.sum(sample_is_robust) == 0:
208208
break
209209

210-
target = check_and_transform_label_format(targeted_labels[:, i], self.estimator.nb_classes)
210+
target = check_and_transform_label_format(
211+
targeted_labels[:, i], nb_classes=self.estimator.nb_classes
212+
)
211213

212214
x_adv, sample_is_robust = self._run_attack(
213215
x=x_adv,

art/attacks/evasion/auto_projected_gradient_descent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
376376
mask = kwargs.get("mask")
377377

378378
if y is not None:
379-
y = check_and_transform_label_format(y, self.estimator.nb_classes)
379+
y = check_and_transform_label_format(y, nb_classes=self.estimator.nb_classes)
380380

381381
if y is None:
382382
if self.targeted:

art/attacks/evasion/boundary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
131131
# Use model predictions as correct outputs
132132
y = get_labels_np_array(self.estimator.predict(x, batch_size=self.batch_size)) # type: ignore
133133

134-
y = check_and_transform_label_format(y, self.estimator.nb_classes, return_one_hot=False)
134+
y = check_and_transform_label_format(y, nb_classes=self.estimator.nb_classes, return_one_hot=False)
135135

136136
if y is not None and self.estimator.nb_classes == 2 and y.shape[1] == 1:
137137
raise ValueError( # pragma: no cover

art/attacks/evasion/brendel_bethge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2186,7 +2186,7 @@ def generate(
21862186
originals = x.copy()
21872187

21882188
if y is not None:
2189-
y = check_and_transform_label_format(y, self.estimator.nb_classes)
2189+
y = check_and_transform_label_format(y, nb_classes=self.estimator.nb_classes)
21902190

21912191
if y is None:
21922192
# Throw error if attack is targeted, but no targets are provided

art/attacks/evasion/carlini.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
238238
:return: An array holding the adversarial examples.
239239
"""
240240
if y is not None:
241-
y = check_and_transform_label_format(y, self.estimator.nb_classes)
241+
y = check_and_transform_label_format(y, nb_classes=self.estimator.nb_classes)
242242
x_adv = x.astype(ART_NUMPY_DTYPE)
243243

244244
if self.estimator.clip_values is not None:
@@ -743,7 +743,7 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
743743
:return: An array holding the adversarial examples.
744744
"""
745745
if y is not None:
746-
y = check_and_transform_label_format(y, self.estimator.nb_classes)
746+
y = check_and_transform_label_format(y, nb_classes=self.estimator.nb_classes)
747747
x_adv = x.astype(ART_NUMPY_DTYPE)
748748

749749
if self.estimator.clip_values is not None:
@@ -953,7 +953,7 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
953953
:return: An array holding the adversarial examples.
954954
"""
955955
if y is not None:
956-
y = check_and_transform_label_format(y, self.estimator.nb_classes)
956+
y = check_and_transform_label_format(y, nb_classes=self.estimator.nb_classes)
957957
x_adv = x.astype(ART_NUMPY_DTYPE)
958958

959959
if self.estimator.clip_values is not None:

art/attacks/evasion/decision_tree_attack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
115115
:return: An array holding the adversarial examples.
116116
"""
117117
if y is not None:
118-
y = check_and_transform_label_format(y, self.estimator.nb_classes, return_one_hot=False)
118+
y = check_and_transform_label_format(y, nb_classes=self.estimator.nb_classes, return_one_hot=False)
119119
x_adv = x.copy()
120120

121121
for index in trange(x_adv.shape[0], desc="Decision tree attack", disable=not self.verbose):

art/attacks/evasion/elastic_net.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
205205
:return: An array holding the adversarial examples.
206206
"""
207207
if y is not None:
208-
y = check_and_transform_label_format(y, self.estimator.nb_classes)
208+
y = check_and_transform_label_format(y, nb_classes=self.estimator.nb_classes)
209209
x_adv = x.astype(ART_NUMPY_DTYPE)
210210

211211
# Assert that, if attack is targeted, y is provided:

art/attacks/evasion/fast_gradient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
225225

226226
if isinstance(self.estimator, ClassifierMixin):
227227
if y is not None:
228-
y = check_and_transform_label_format(y, self.estimator.nb_classes)
228+
y = check_and_transform_label_format(y, nb_classes=self.estimator.nb_classes)
229229

230230
if y is None:
231231
# Throw error if attack is targeted, but no targets are provided

art/attacks/evasion/geometric_decision_based_attack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
169169
:return: The adversarial examples.
170170
"""
171171
if y is not None:
172-
y = check_and_transform_label_format(y, self.estimator.nb_classes, return_one_hot=True)
172+
y = check_and_transform_label_format(y, nb_classes=self.estimator.nb_classes, return_one_hot=True)
173173

174174
if y is not None and self.estimator.nb_classes == 2 and y.shape[1] == 1: # pragma: no cover
175175
raise ValueError(

art/attacks/evasion/hop_skip_jump.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
133133
# Use model predictions as correct outputs
134134
y = get_labels_np_array(self.estimator.predict(x, batch_size=self.batch_size)) # type: ignore
135135

136-
y = check_and_transform_label_format(y, self.estimator.nb_classes)
136+
y = check_and_transform_label_format(y, nb_classes=self.estimator.nb_classes)
137137

138138
if self.estimator.nb_classes == 2 and y.shape[1] == 1: # pragma: no cover
139139
raise ValueError(

0 commit comments

Comments
 (0)