Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canonical type comparison #2492

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions art/attacks/evasion/fast_gradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion art/estimators/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading