diff --git a/art/attacks/evasion/fast_gradient.py b/art/attacks/evasion/fast_gradient.py index 80571469b7..0867332756 100644 --- a/art/attacks/evasion/fast_gradient.py +++ b/art/attacks/evasion/fast_gradient.py @@ -476,7 +476,7 @@ def _apply_perturbation( ) -> np.ndarray: perturbation_step = eps_step * perturbation - if perturbation_step.dtype != object: + if perturbation_step.dtype is not object: perturbation_step[np.isnan(perturbation_step)] = 0 else: for i, _ in enumerate(perturbation_step): @@ -489,7 +489,7 @@ def _apply_perturbation( x = x + perturbation_step if self.estimator.clip_values is not None: clip_min, clip_max = self.estimator.clip_values - if x.dtype == object: + if x.dtype is object: for i_obj in range(x.shape[0]): x[i_obj] = np.clip(x[i_obj], clip_min, clip_max) else: diff --git a/art/estimators/tensorflow.py b/art/estimators/tensorflow.py index d175d23fd8..f0d54085fb 100644 --- a/art/estimators/tensorflow.py +++ b/art/estimators/tensorflow.py @@ -181,7 +181,7 @@ def _apply_preprocessing(self, x, y, fit: bool = False) -> tuple[Any, Any]: input_is_tensor = isinstance(x, tf.Tensor) - if self.all_framework_preprocessing and not (not input_is_tensor and x.dtype == object): + if self.all_framework_preprocessing and not (not input_is_tensor and x.dtype is object): # Convert np arrays to torch tensors. if not input_is_tensor: x = tf.convert_to_tensor(x)