Skip to content

Commit 63916b2

Browse files
committed
mypy fixes
Signed-off-by: GiulioZizzo <[email protected]>
1 parent 56f7f4a commit 63916b2

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

art/estimators/certification/randomized_smoothing/pytorch.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,20 @@ def fit( # pylint: disable=W0221
222222
if scheduler is not None:
223223
scheduler.step()
224224

225-
def predict(self, x: np.ndarray, batch_size: int = 128, **kwargs) -> np.ndarray: # type: ignore
225+
def predict(self, x: np.ndarray, batch_size: int = 128, verbose: bool = False, **kwargs) -> np.ndarray: # type: ignore
226226
"""
227227
Perform prediction of the given classifier for a batch of inputs, taking an expectation over transformations.
228228
229229
:param x: Input samples.
230230
:param batch_size: Batch size.
231+
:param verbose: Display training progress bar.
231232
:param is_abstain: True if function will abstain from prediction and return 0s. Default: True
232233
:type is_abstain: `boolean`
233234
:return: Array of predictions of shape `(nb_inputs, nb_classes)`.
234235
"""
235-
return RandomizedSmoothingMixin.predict(self, x, batch_size=batch_size, training_mode=False, **kwargs)
236+
return RandomizedSmoothingMixin.predict(
237+
self, x, batch_size=batch_size, verbose=verbose, training_mode=False, **kwargs
238+
)
236239

237240
def loss_gradient( # type: ignore
238241
self, x: np.ndarray, y: np.ndarray, training_mode: bool = False, **kwargs

art/estimators/certification/randomized_smoothing/smooth_adv/tensorflow.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ def __init__(
125125
sample_size=sample_size,
126126
scale=scale,
127127
alpha=alpha,
128-
verbose=verbose,
129128
)
130129
self.epsilon = epsilon
131130
self.num_noise_vec = num_noise_vec

art/estimators/certification/randomized_smoothing/tensorflow.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ def __init__(
7070
sample_size: int = 32,
7171
scale: float = 0.1,
7272
alpha: float = 0.001,
73-
verbose: bool = False,
7473
):
7574
"""
7675
Create a randomized smoothing classifier.
@@ -192,17 +191,20 @@ def train_step(model, images, labels):
192191
if scheduler is not None:
193192
scheduler(epoch)
194193

195-
def predict(self, x: np.ndarray, batch_size: int = 128, **kwargs) -> np.ndarray: # type: ignore
194+
def predict(self, x: np.ndarray, batch_size: int = 128, verbose: bool = False, **kwargs) -> np.ndarray: # type: ignore
196195
"""
197196
Perform prediction of the given classifier for a batch of inputs, taking an expectation over transformations.
198197
199198
:param x: Input samples.
200199
:param batch_size: Batch size.
200+
:param verbose: Display training progress bar.
201201
:param is_abstain: True if function will abstain from prediction and return 0s. Default: True
202202
:type is_abstain: `boolean`
203203
:return: Array of predictions of shape `(nb_inputs, nb_classes)`.
204204
"""
205-
return RandomizedSmoothingMixin.predict(self, x, batch_size=batch_size, training_mode=False, **kwargs)
205+
return RandomizedSmoothingMixin.predict(
206+
self, x, batch_size=batch_size, verbose=verbose, training_mode=False, **kwargs
207+
)
206208

207209
def loss_gradient(self, x: np.ndarray, y: np.ndarray, training_mode: bool = False, **kwargs) -> np.ndarray:
208210
"""

0 commit comments

Comments
 (0)