Skip to content

Commit

Permalink
general inclusion of pylint: disable=W0221. Updates to randomized/der…
Browse files Browse the repository at this point in the history
…andomized tools

Signed-off-by: GiulioZizzo <[email protected]>
  • Loading branch information
GiulioZizzo committed Dec 18, 2023
1 parent cc441c9 commit 9c3f572
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 77 deletions.
11 changes: 1 addition & 10 deletions art/estimators/certification/derandomized_smoothing/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,16 +469,7 @@ def fit( # pylint: disable=W0221
"""
import torch

if verbose is not None:
if isinstance(verbose, int):
if verbose == 0:
display_pb = False
else:
display_pb = True
else:
display_pb = verbose
else:
display_pb = False
display_pb = self.process_verbose(verbose)

# Set model mode
self._model.train(mode=training_mode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,7 @@ def fit( # pylint: disable=W0221
"""
import tensorflow as tf

if verbose is not None:
if isinstance(verbose, int):
if verbose == 0:
display_pb = False
else:
display_pb = True
else:
display_pb = verbose
else:
display_pb = False
display_pb = self.process_verbose(verbose)

if self._train_step is None: # pragma: no cover
if self._loss_object is None: # pragma: no cover
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,7 @@ class was initialised.
import torch.nn.functional as F
from torch.utils.data import TensorDataset, DataLoader

if verbose is not None:
if isinstance(verbose, int):
if verbose == 0:
display_pb = False
else:
display_pb = True
else:
display_pb = verbose
else:
display_pb = self.verbose
display_pb = self.process_verbose(verbose)

# Set model mode
self._model.train(mode=training_mode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,7 @@ class was initialised.
"""
import tensorflow as tf

if verbose is not None:
if isinstance(verbose, int):
if verbose == 0:
display_pb = False
else:
display_pb = True
else:
display_pb = verbose
else:
display_pb = self.verbose
display_pb = self.process_verbose(verbose)

if self._train_step is None: # pragma: no cover
if self._optimizer is None: # pragma: no cover
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,7 @@ class was initialised.
import torch
from torch.utils.data import TensorDataset, DataLoader

if verbose is not None:
if isinstance(verbose, int):
if verbose == 0:
display_pb = False
else:
display_pb = True
else:
display_pb = verbose
else:
display_pb = self.verbose
display_pb = self.process_verbose(verbose)

# Set model mode
self._model.train(mode=training_mode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,7 @@ class was initialised.
"""
import tensorflow as tf

if verbose is not None:
if isinstance(verbose, int):
if verbose == 0:
display_pb = False
else:
display_pb = True
else:
display_pb = verbose
else:
display_pb = self.verbose
display_pb = self.process_verbose(verbose)

if self._train_step is None: # pragma: no cover
if self._loss_object is None: # pragma: no cover
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,7 @@ class was initialised.
import torch.nn.functional as F
from torch.utils.data import TensorDataset, DataLoader

if verbose is not None:
if isinstance(verbose, int):
if verbose == 0:
display_pb = False
else:
display_pb = True
else:
display_pb = verbose
else:
display_pb = self.verbose
display_pb = self.process_verbose(verbose)

# Set model mode
self._model.train(mode=training_mode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def _predict_classifier(self, x: np.ndarray, batch_size: int, training_mode: boo
def _fit_classifier(self, x: np.ndarray, y: np.ndarray, batch_size: int, nb_epochs: int, **kwargs) -> None:
return TensorFlowV2Classifier.fit(self, x, y, batch_size=batch_size, nb_epochs=nb_epochs, **kwargs)

def fit(
def fit( # pylint: disable=W0221
self,
x: np.ndarray,
y: np.ndarray,
Expand Down
4 changes: 2 additions & 2 deletions art/estimators/classification/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def process_verbose(self, verbose: Optional[Union[bool, int]] = None) -> bool:
else:
# Check if the verbose attribute is present in the current classifier
if hasattr(self, "verbose"):
display_pb = self.verbose
display_pb = self.verbose # type: ignore
# else default to False
else:
display_pb = False
Expand Down Expand Up @@ -487,7 +487,7 @@ def fit( # pylint: disable=W0221
if scheduler is not None:
scheduler.step()

def fit_generator(
def fit_generator( # pylint: disable=W0221
self, generator: "DataGenerator", nb_epochs: int = 20, verbose: Optional[Union[bool, int]] = None, **kwargs
) -> None:
"""
Expand Down
8 changes: 4 additions & 4 deletions art/estimators/classification/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def process_verbose(self, verbose: Optional[Union[bool, int]] = None) -> bool:
else:
# Check if the verbose attribute is present in the current classifier
if hasattr(self, "verbose"):
display_pb = self.verbose
display_pb = self.verbose # type: ignore
# else default to False
else:
display_pb = False
Expand Down Expand Up @@ -1024,14 +1024,14 @@ def process_verbose(self, verbose: Optional[Union[bool, int]] = None) -> bool:
else:
# Check if the verbose attribute is present in the current classifier
if hasattr(self, "verbose"):
display_pb = self.verbose
display_pb = self.verbose # type: ignore
# else default to False
else:
display_pb = False

return display_pb

def fit(
def fit( # pylint: disable=W0221
self,
x: np.ndarray,
y: np.ndarray,
Expand Down Expand Up @@ -1100,7 +1100,7 @@ def train_step(model, images, labels):
if scheduler is not None:
scheduler(epoch)

def fit_generator(
def fit_generator( # pylint: disable=W0221
self, generator: "DataGenerator", nb_epochs: int = 20, verbose: Optional[Union[bool, int]] = None, **kwargs
) -> None:
"""
Expand Down

0 comments on commit 9c3f572

Please sign in to comment.