From 6f089a0682fb21e98c9d050fcc258d8147e0fba8 Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 09:27:24 +0200 Subject: [PATCH 01/25] moved attacks to attacks_v1 --- foolbox/{attacks => attacks_v1}/__init__.py | 0 foolbox/{attacks => attacks_v1}/additive_noise.py | 0 foolbox/{attacks => attacks_v1}/adef_attack.py | 0 foolbox/{attacks => attacks_v1}/base.py | 0 foolbox/{attacks => attacks_v1}/binarization.py | 0 foolbox/{attacks => attacks_v1}/blended_noise.py | 0 foolbox/{attacks => attacks_v1}/blur.py | 0 foolbox/{attacks => attacks_v1}/boundary_attack.py | 0 foolbox/{attacks => attacks_v1}/carlini_wagner.py | 0 foolbox/{attacks => attacks_v1}/contrast.py | 0 foolbox/{attacks => attacks_v1}/decoupled_direction_norm.py | 0 foolbox/{attacks => attacks_v1}/deepfool.py | 0 foolbox/{attacks => attacks_v1}/ead.py | 0 foolbox/{attacks => attacks_v1}/gradient.py | 0 foolbox/{attacks => attacks_v1}/hop_skip_jump_attack.py | 0 foolbox/{attacks => attacks_v1}/iterative_gradient.py | 0 foolbox/{attacks => attacks_v1}/iterative_projected_gradient.py | 0 foolbox/{attacks => attacks_v1}/lbfgs.py | 0 foolbox/{attacks => attacks_v1}/localsearch.py | 0 foolbox/{attacks => attacks_v1}/newtonfool.py | 0 foolbox/{attacks => attacks_v1}/pointwise.py | 0 foolbox/{attacks => attacks_v1}/precomputed.py | 0 foolbox/{attacks => attacks_v1}/saliency.py | 0 foolbox/{attacks => attacks_v1}/saltandpepper.py | 0 foolbox/{attacks => attacks_v1}/slsqp.py | 0 foolbox/{attacks => attacks_v1}/sparsefool.py | 0 foolbox/{attacks => attacks_v1}/spatial.py | 0 27 files changed, 0 insertions(+), 0 deletions(-) rename foolbox/{attacks => attacks_v1}/__init__.py (100%) rename foolbox/{attacks => attacks_v1}/additive_noise.py (100%) rename foolbox/{attacks => attacks_v1}/adef_attack.py (100%) rename foolbox/{attacks => attacks_v1}/base.py (100%) rename foolbox/{attacks => attacks_v1}/binarization.py (100%) rename foolbox/{attacks => attacks_v1}/blended_noise.py (100%) rename foolbox/{attacks => attacks_v1}/blur.py (100%) rename foolbox/{attacks => attacks_v1}/boundary_attack.py (100%) rename foolbox/{attacks => attacks_v1}/carlini_wagner.py (100%) rename foolbox/{attacks => attacks_v1}/contrast.py (100%) rename foolbox/{attacks => attacks_v1}/decoupled_direction_norm.py (100%) rename foolbox/{attacks => attacks_v1}/deepfool.py (100%) rename foolbox/{attacks => attacks_v1}/ead.py (100%) rename foolbox/{attacks => attacks_v1}/gradient.py (100%) rename foolbox/{attacks => attacks_v1}/hop_skip_jump_attack.py (100%) rename foolbox/{attacks => attacks_v1}/iterative_gradient.py (100%) rename foolbox/{attacks => attacks_v1}/iterative_projected_gradient.py (100%) rename foolbox/{attacks => attacks_v1}/lbfgs.py (100%) rename foolbox/{attacks => attacks_v1}/localsearch.py (100%) rename foolbox/{attacks => attacks_v1}/newtonfool.py (100%) rename foolbox/{attacks => attacks_v1}/pointwise.py (100%) rename foolbox/{attacks => attacks_v1}/precomputed.py (100%) rename foolbox/{attacks => attacks_v1}/saliency.py (100%) rename foolbox/{attacks => attacks_v1}/saltandpepper.py (100%) rename foolbox/{attacks => attacks_v1}/slsqp.py (100%) rename foolbox/{attacks => attacks_v1}/sparsefool.py (100%) rename foolbox/{attacks => attacks_v1}/spatial.py (100%) diff --git a/foolbox/attacks/__init__.py b/foolbox/attacks_v1/__init__.py similarity index 100% rename from foolbox/attacks/__init__.py rename to foolbox/attacks_v1/__init__.py diff --git a/foolbox/attacks/additive_noise.py b/foolbox/attacks_v1/additive_noise.py similarity index 100% rename from foolbox/attacks/additive_noise.py rename to foolbox/attacks_v1/additive_noise.py diff --git a/foolbox/attacks/adef_attack.py b/foolbox/attacks_v1/adef_attack.py similarity index 100% rename from foolbox/attacks/adef_attack.py rename to foolbox/attacks_v1/adef_attack.py diff --git a/foolbox/attacks/base.py b/foolbox/attacks_v1/base.py similarity index 100% rename from foolbox/attacks/base.py rename to foolbox/attacks_v1/base.py diff --git a/foolbox/attacks/binarization.py b/foolbox/attacks_v1/binarization.py similarity index 100% rename from foolbox/attacks/binarization.py rename to foolbox/attacks_v1/binarization.py diff --git a/foolbox/attacks/blended_noise.py b/foolbox/attacks_v1/blended_noise.py similarity index 100% rename from foolbox/attacks/blended_noise.py rename to foolbox/attacks_v1/blended_noise.py diff --git a/foolbox/attacks/blur.py b/foolbox/attacks_v1/blur.py similarity index 100% rename from foolbox/attacks/blur.py rename to foolbox/attacks_v1/blur.py diff --git a/foolbox/attacks/boundary_attack.py b/foolbox/attacks_v1/boundary_attack.py similarity index 100% rename from foolbox/attacks/boundary_attack.py rename to foolbox/attacks_v1/boundary_attack.py diff --git a/foolbox/attacks/carlini_wagner.py b/foolbox/attacks_v1/carlini_wagner.py similarity index 100% rename from foolbox/attacks/carlini_wagner.py rename to foolbox/attacks_v1/carlini_wagner.py diff --git a/foolbox/attacks/contrast.py b/foolbox/attacks_v1/contrast.py similarity index 100% rename from foolbox/attacks/contrast.py rename to foolbox/attacks_v1/contrast.py diff --git a/foolbox/attacks/decoupled_direction_norm.py b/foolbox/attacks_v1/decoupled_direction_norm.py similarity index 100% rename from foolbox/attacks/decoupled_direction_norm.py rename to foolbox/attacks_v1/decoupled_direction_norm.py diff --git a/foolbox/attacks/deepfool.py b/foolbox/attacks_v1/deepfool.py similarity index 100% rename from foolbox/attacks/deepfool.py rename to foolbox/attacks_v1/deepfool.py diff --git a/foolbox/attacks/ead.py b/foolbox/attacks_v1/ead.py similarity index 100% rename from foolbox/attacks/ead.py rename to foolbox/attacks_v1/ead.py diff --git a/foolbox/attacks/gradient.py b/foolbox/attacks_v1/gradient.py similarity index 100% rename from foolbox/attacks/gradient.py rename to foolbox/attacks_v1/gradient.py diff --git a/foolbox/attacks/hop_skip_jump_attack.py b/foolbox/attacks_v1/hop_skip_jump_attack.py similarity index 100% rename from foolbox/attacks/hop_skip_jump_attack.py rename to foolbox/attacks_v1/hop_skip_jump_attack.py diff --git a/foolbox/attacks/iterative_gradient.py b/foolbox/attacks_v1/iterative_gradient.py similarity index 100% rename from foolbox/attacks/iterative_gradient.py rename to foolbox/attacks_v1/iterative_gradient.py diff --git a/foolbox/attacks/iterative_projected_gradient.py b/foolbox/attacks_v1/iterative_projected_gradient.py similarity index 100% rename from foolbox/attacks/iterative_projected_gradient.py rename to foolbox/attacks_v1/iterative_projected_gradient.py diff --git a/foolbox/attacks/lbfgs.py b/foolbox/attacks_v1/lbfgs.py similarity index 100% rename from foolbox/attacks/lbfgs.py rename to foolbox/attacks_v1/lbfgs.py diff --git a/foolbox/attacks/localsearch.py b/foolbox/attacks_v1/localsearch.py similarity index 100% rename from foolbox/attacks/localsearch.py rename to foolbox/attacks_v1/localsearch.py diff --git a/foolbox/attacks/newtonfool.py b/foolbox/attacks_v1/newtonfool.py similarity index 100% rename from foolbox/attacks/newtonfool.py rename to foolbox/attacks_v1/newtonfool.py diff --git a/foolbox/attacks/pointwise.py b/foolbox/attacks_v1/pointwise.py similarity index 100% rename from foolbox/attacks/pointwise.py rename to foolbox/attacks_v1/pointwise.py diff --git a/foolbox/attacks/precomputed.py b/foolbox/attacks_v1/precomputed.py similarity index 100% rename from foolbox/attacks/precomputed.py rename to foolbox/attacks_v1/precomputed.py diff --git a/foolbox/attacks/saliency.py b/foolbox/attacks_v1/saliency.py similarity index 100% rename from foolbox/attacks/saliency.py rename to foolbox/attacks_v1/saliency.py diff --git a/foolbox/attacks/saltandpepper.py b/foolbox/attacks_v1/saltandpepper.py similarity index 100% rename from foolbox/attacks/saltandpepper.py rename to foolbox/attacks_v1/saltandpepper.py diff --git a/foolbox/attacks/slsqp.py b/foolbox/attacks_v1/slsqp.py similarity index 100% rename from foolbox/attacks/slsqp.py rename to foolbox/attacks_v1/slsqp.py diff --git a/foolbox/attacks/sparsefool.py b/foolbox/attacks_v1/sparsefool.py similarity index 100% rename from foolbox/attacks/sparsefool.py rename to foolbox/attacks_v1/sparsefool.py diff --git a/foolbox/attacks/spatial.py b/foolbox/attacks_v1/spatial.py similarity index 100% rename from foolbox/attacks/spatial.py rename to foolbox/attacks_v1/spatial.py From 629003fff4365b6734687067d686c9a9dff17ca7 Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 09:28:09 +0200 Subject: [PATCH 02/25] moved batch_attacks to attacks --- foolbox/{batch_attacks => attacks}/__init__.py | 0 foolbox/{batch_attacks => attacks}/additive_noise.py | 0 foolbox/{batch_attacks => attacks}/adef_attack.py | 0 foolbox/{batch_attacks => attacks}/base.py | 0 foolbox/{batch_attacks => attacks}/binarization.py | 0 foolbox/{batch_attacks => attacks}/blended_noise.py | 0 foolbox/{batch_attacks => attacks}/blur.py | 0 foolbox/{batch_attacks => attacks}/boundary_attack.py | 0 foolbox/{batch_attacks => attacks}/carlini_wagner.py | 0 foolbox/{batch_attacks => attacks}/contrast.py | 0 foolbox/{batch_attacks => attacks}/decoupled_direction_norm.py | 0 foolbox/{batch_attacks => attacks}/deepfool.py | 0 foolbox/{batch_attacks => attacks}/ead.py | 0 foolbox/{batch_attacks => attacks}/gen.py | 0 foolbox/{batch_attacks => attacks}/gradient.py | 0 foolbox/{batch_attacks => attacks}/hop_skip_jump_attack.py | 0 foolbox/{batch_attacks => attacks}/inversion.py | 0 foolbox/{batch_attacks => attacks}/iterative_gradient.py | 0 .../{batch_attacks => attacks}/iterative_projected_gradient.py | 0 foolbox/{batch_attacks => attacks}/localsearch.py | 0 foolbox/{batch_attacks => attacks}/newtonfool.py | 0 foolbox/{batch_attacks => attacks}/pointwise.py | 0 foolbox/{batch_attacks => attacks}/precomputed.py | 0 foolbox/{batch_attacks => attacks}/saliency.py | 0 foolbox/{batch_attacks => attacks}/saltandpepper.py | 0 foolbox/{batch_attacks => attacks}/spatial.py | 0 foolbox/{batch_attacks => attacks}/virtual_adversarial.py | 0 27 files changed, 0 insertions(+), 0 deletions(-) rename foolbox/{batch_attacks => attacks}/__init__.py (100%) rename foolbox/{batch_attacks => attacks}/additive_noise.py (100%) rename foolbox/{batch_attacks => attacks}/adef_attack.py (100%) rename foolbox/{batch_attacks => attacks}/base.py (100%) rename foolbox/{batch_attacks => attacks}/binarization.py (100%) rename foolbox/{batch_attacks => attacks}/blended_noise.py (100%) rename foolbox/{batch_attacks => attacks}/blur.py (100%) rename foolbox/{batch_attacks => attacks}/boundary_attack.py (100%) rename foolbox/{batch_attacks => attacks}/carlini_wagner.py (100%) rename foolbox/{batch_attacks => attacks}/contrast.py (100%) rename foolbox/{batch_attacks => attacks}/decoupled_direction_norm.py (100%) rename foolbox/{batch_attacks => attacks}/deepfool.py (100%) rename foolbox/{batch_attacks => attacks}/ead.py (100%) rename foolbox/{batch_attacks => attacks}/gen.py (100%) rename foolbox/{batch_attacks => attacks}/gradient.py (100%) rename foolbox/{batch_attacks => attacks}/hop_skip_jump_attack.py (100%) rename foolbox/{batch_attacks => attacks}/inversion.py (100%) rename foolbox/{batch_attacks => attacks}/iterative_gradient.py (100%) rename foolbox/{batch_attacks => attacks}/iterative_projected_gradient.py (100%) rename foolbox/{batch_attacks => attacks}/localsearch.py (100%) rename foolbox/{batch_attacks => attacks}/newtonfool.py (100%) rename foolbox/{batch_attacks => attacks}/pointwise.py (100%) rename foolbox/{batch_attacks => attacks}/precomputed.py (100%) rename foolbox/{batch_attacks => attacks}/saliency.py (100%) rename foolbox/{batch_attacks => attacks}/saltandpepper.py (100%) rename foolbox/{batch_attacks => attacks}/spatial.py (100%) rename foolbox/{batch_attacks => attacks}/virtual_adversarial.py (100%) diff --git a/foolbox/batch_attacks/__init__.py b/foolbox/attacks/__init__.py similarity index 100% rename from foolbox/batch_attacks/__init__.py rename to foolbox/attacks/__init__.py diff --git a/foolbox/batch_attacks/additive_noise.py b/foolbox/attacks/additive_noise.py similarity index 100% rename from foolbox/batch_attacks/additive_noise.py rename to foolbox/attacks/additive_noise.py diff --git a/foolbox/batch_attacks/adef_attack.py b/foolbox/attacks/adef_attack.py similarity index 100% rename from foolbox/batch_attacks/adef_attack.py rename to foolbox/attacks/adef_attack.py diff --git a/foolbox/batch_attacks/base.py b/foolbox/attacks/base.py similarity index 100% rename from foolbox/batch_attacks/base.py rename to foolbox/attacks/base.py diff --git a/foolbox/batch_attacks/binarization.py b/foolbox/attacks/binarization.py similarity index 100% rename from foolbox/batch_attacks/binarization.py rename to foolbox/attacks/binarization.py diff --git a/foolbox/batch_attacks/blended_noise.py b/foolbox/attacks/blended_noise.py similarity index 100% rename from foolbox/batch_attacks/blended_noise.py rename to foolbox/attacks/blended_noise.py diff --git a/foolbox/batch_attacks/blur.py b/foolbox/attacks/blur.py similarity index 100% rename from foolbox/batch_attacks/blur.py rename to foolbox/attacks/blur.py diff --git a/foolbox/batch_attacks/boundary_attack.py b/foolbox/attacks/boundary_attack.py similarity index 100% rename from foolbox/batch_attacks/boundary_attack.py rename to foolbox/attacks/boundary_attack.py diff --git a/foolbox/batch_attacks/carlini_wagner.py b/foolbox/attacks/carlini_wagner.py similarity index 100% rename from foolbox/batch_attacks/carlini_wagner.py rename to foolbox/attacks/carlini_wagner.py diff --git a/foolbox/batch_attacks/contrast.py b/foolbox/attacks/contrast.py similarity index 100% rename from foolbox/batch_attacks/contrast.py rename to foolbox/attacks/contrast.py diff --git a/foolbox/batch_attacks/decoupled_direction_norm.py b/foolbox/attacks/decoupled_direction_norm.py similarity index 100% rename from foolbox/batch_attacks/decoupled_direction_norm.py rename to foolbox/attacks/decoupled_direction_norm.py diff --git a/foolbox/batch_attacks/deepfool.py b/foolbox/attacks/deepfool.py similarity index 100% rename from foolbox/batch_attacks/deepfool.py rename to foolbox/attacks/deepfool.py diff --git a/foolbox/batch_attacks/ead.py b/foolbox/attacks/ead.py similarity index 100% rename from foolbox/batch_attacks/ead.py rename to foolbox/attacks/ead.py diff --git a/foolbox/batch_attacks/gen.py b/foolbox/attacks/gen.py similarity index 100% rename from foolbox/batch_attacks/gen.py rename to foolbox/attacks/gen.py diff --git a/foolbox/batch_attacks/gradient.py b/foolbox/attacks/gradient.py similarity index 100% rename from foolbox/batch_attacks/gradient.py rename to foolbox/attacks/gradient.py diff --git a/foolbox/batch_attacks/hop_skip_jump_attack.py b/foolbox/attacks/hop_skip_jump_attack.py similarity index 100% rename from foolbox/batch_attacks/hop_skip_jump_attack.py rename to foolbox/attacks/hop_skip_jump_attack.py diff --git a/foolbox/batch_attacks/inversion.py b/foolbox/attacks/inversion.py similarity index 100% rename from foolbox/batch_attacks/inversion.py rename to foolbox/attacks/inversion.py diff --git a/foolbox/batch_attacks/iterative_gradient.py b/foolbox/attacks/iterative_gradient.py similarity index 100% rename from foolbox/batch_attacks/iterative_gradient.py rename to foolbox/attacks/iterative_gradient.py diff --git a/foolbox/batch_attacks/iterative_projected_gradient.py b/foolbox/attacks/iterative_projected_gradient.py similarity index 100% rename from foolbox/batch_attacks/iterative_projected_gradient.py rename to foolbox/attacks/iterative_projected_gradient.py diff --git a/foolbox/batch_attacks/localsearch.py b/foolbox/attacks/localsearch.py similarity index 100% rename from foolbox/batch_attacks/localsearch.py rename to foolbox/attacks/localsearch.py diff --git a/foolbox/batch_attacks/newtonfool.py b/foolbox/attacks/newtonfool.py similarity index 100% rename from foolbox/batch_attacks/newtonfool.py rename to foolbox/attacks/newtonfool.py diff --git a/foolbox/batch_attacks/pointwise.py b/foolbox/attacks/pointwise.py similarity index 100% rename from foolbox/batch_attacks/pointwise.py rename to foolbox/attacks/pointwise.py diff --git a/foolbox/batch_attacks/precomputed.py b/foolbox/attacks/precomputed.py similarity index 100% rename from foolbox/batch_attacks/precomputed.py rename to foolbox/attacks/precomputed.py diff --git a/foolbox/batch_attacks/saliency.py b/foolbox/attacks/saliency.py similarity index 100% rename from foolbox/batch_attacks/saliency.py rename to foolbox/attacks/saliency.py diff --git a/foolbox/batch_attacks/saltandpepper.py b/foolbox/attacks/saltandpepper.py similarity index 100% rename from foolbox/batch_attacks/saltandpepper.py rename to foolbox/attacks/saltandpepper.py diff --git a/foolbox/batch_attacks/spatial.py b/foolbox/attacks/spatial.py similarity index 100% rename from foolbox/batch_attacks/spatial.py rename to foolbox/attacks/spatial.py diff --git a/foolbox/batch_attacks/virtual_adversarial.py b/foolbox/attacks/virtual_adversarial.py similarity index 100% rename from foolbox/batch_attacks/virtual_adversarial.py rename to foolbox/attacks/virtual_adversarial.py From a8cfdb93096224ce2fef4c5bc1a2c169b6bab71a Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 09:28:46 +0200 Subject: [PATCH 03/25] updated import --- foolbox/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foolbox/__init__.py b/foolbox/__init__.py index 22afd3f6..f30f1588 100755 --- a/foolbox/__init__.py +++ b/foolbox/__init__.py @@ -11,7 +11,7 @@ from . import criteria # noqa: F401 from . import distances # noqa: F401 from . import attacks # noqa: F401 -from . import batch_attacks # noqa: F401 +from . import attacks_v1 # noqa: F401 from . import utils # noqa: F401 from . import gradient_estimators # noqa: F401 From 42c00f2299eeacdf5c63b5bcf012c682a9113433 Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 09:35:41 +0200 Subject: [PATCH 04/25] moved attacks_v1 to v1/attacks --- foolbox/{attacks_v1 => v1/attacks}/__init__.py | 0 foolbox/{attacks_v1 => v1/attacks}/additive_noise.py | 0 foolbox/{attacks_v1 => v1/attacks}/adef_attack.py | 0 foolbox/{attacks_v1 => v1/attacks}/base.py | 0 foolbox/{attacks_v1 => v1/attacks}/binarization.py | 0 foolbox/{attacks_v1 => v1/attacks}/blended_noise.py | 0 foolbox/{attacks_v1 => v1/attacks}/blur.py | 0 foolbox/{attacks_v1 => v1/attacks}/boundary_attack.py | 0 foolbox/{attacks_v1 => v1/attacks}/carlini_wagner.py | 0 foolbox/{attacks_v1 => v1/attacks}/contrast.py | 0 foolbox/{attacks_v1 => v1/attacks}/decoupled_direction_norm.py | 0 foolbox/{attacks_v1 => v1/attacks}/deepfool.py | 0 foolbox/{attacks_v1 => v1/attacks}/ead.py | 0 foolbox/{attacks_v1 => v1/attacks}/gradient.py | 0 foolbox/{attacks_v1 => v1/attacks}/hop_skip_jump_attack.py | 0 foolbox/{attacks_v1 => v1/attacks}/iterative_gradient.py | 0 .../{attacks_v1 => v1/attacks}/iterative_projected_gradient.py | 0 foolbox/{attacks_v1 => v1/attacks}/lbfgs.py | 0 foolbox/{attacks_v1 => v1/attacks}/localsearch.py | 0 foolbox/{attacks_v1 => v1/attacks}/newtonfool.py | 0 foolbox/{attacks_v1 => v1/attacks}/pointwise.py | 0 foolbox/{attacks_v1 => v1/attacks}/precomputed.py | 0 foolbox/{attacks_v1 => v1/attacks}/saliency.py | 0 foolbox/{attacks_v1 => v1/attacks}/saltandpepper.py | 0 foolbox/{attacks_v1 => v1/attacks}/slsqp.py | 0 foolbox/{attacks_v1 => v1/attacks}/sparsefool.py | 0 foolbox/{attacks_v1 => v1/attacks}/spatial.py | 0 27 files changed, 0 insertions(+), 0 deletions(-) rename foolbox/{attacks_v1 => v1/attacks}/__init__.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/additive_noise.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/adef_attack.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/base.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/binarization.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/blended_noise.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/blur.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/boundary_attack.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/carlini_wagner.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/contrast.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/decoupled_direction_norm.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/deepfool.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/ead.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/gradient.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/hop_skip_jump_attack.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/iterative_gradient.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/iterative_projected_gradient.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/lbfgs.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/localsearch.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/newtonfool.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/pointwise.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/precomputed.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/saliency.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/saltandpepper.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/slsqp.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/sparsefool.py (100%) rename foolbox/{attacks_v1 => v1/attacks}/spatial.py (100%) diff --git a/foolbox/attacks_v1/__init__.py b/foolbox/v1/attacks/__init__.py similarity index 100% rename from foolbox/attacks_v1/__init__.py rename to foolbox/v1/attacks/__init__.py diff --git a/foolbox/attacks_v1/additive_noise.py b/foolbox/v1/attacks/additive_noise.py similarity index 100% rename from foolbox/attacks_v1/additive_noise.py rename to foolbox/v1/attacks/additive_noise.py diff --git a/foolbox/attacks_v1/adef_attack.py b/foolbox/v1/attacks/adef_attack.py similarity index 100% rename from foolbox/attacks_v1/adef_attack.py rename to foolbox/v1/attacks/adef_attack.py diff --git a/foolbox/attacks_v1/base.py b/foolbox/v1/attacks/base.py similarity index 100% rename from foolbox/attacks_v1/base.py rename to foolbox/v1/attacks/base.py diff --git a/foolbox/attacks_v1/binarization.py b/foolbox/v1/attacks/binarization.py similarity index 100% rename from foolbox/attacks_v1/binarization.py rename to foolbox/v1/attacks/binarization.py diff --git a/foolbox/attacks_v1/blended_noise.py b/foolbox/v1/attacks/blended_noise.py similarity index 100% rename from foolbox/attacks_v1/blended_noise.py rename to foolbox/v1/attacks/blended_noise.py diff --git a/foolbox/attacks_v1/blur.py b/foolbox/v1/attacks/blur.py similarity index 100% rename from foolbox/attacks_v1/blur.py rename to foolbox/v1/attacks/blur.py diff --git a/foolbox/attacks_v1/boundary_attack.py b/foolbox/v1/attacks/boundary_attack.py similarity index 100% rename from foolbox/attacks_v1/boundary_attack.py rename to foolbox/v1/attacks/boundary_attack.py diff --git a/foolbox/attacks_v1/carlini_wagner.py b/foolbox/v1/attacks/carlini_wagner.py similarity index 100% rename from foolbox/attacks_v1/carlini_wagner.py rename to foolbox/v1/attacks/carlini_wagner.py diff --git a/foolbox/attacks_v1/contrast.py b/foolbox/v1/attacks/contrast.py similarity index 100% rename from foolbox/attacks_v1/contrast.py rename to foolbox/v1/attacks/contrast.py diff --git a/foolbox/attacks_v1/decoupled_direction_norm.py b/foolbox/v1/attacks/decoupled_direction_norm.py similarity index 100% rename from foolbox/attacks_v1/decoupled_direction_norm.py rename to foolbox/v1/attacks/decoupled_direction_norm.py diff --git a/foolbox/attacks_v1/deepfool.py b/foolbox/v1/attacks/deepfool.py similarity index 100% rename from foolbox/attacks_v1/deepfool.py rename to foolbox/v1/attacks/deepfool.py diff --git a/foolbox/attacks_v1/ead.py b/foolbox/v1/attacks/ead.py similarity index 100% rename from foolbox/attacks_v1/ead.py rename to foolbox/v1/attacks/ead.py diff --git a/foolbox/attacks_v1/gradient.py b/foolbox/v1/attacks/gradient.py similarity index 100% rename from foolbox/attacks_v1/gradient.py rename to foolbox/v1/attacks/gradient.py diff --git a/foolbox/attacks_v1/hop_skip_jump_attack.py b/foolbox/v1/attacks/hop_skip_jump_attack.py similarity index 100% rename from foolbox/attacks_v1/hop_skip_jump_attack.py rename to foolbox/v1/attacks/hop_skip_jump_attack.py diff --git a/foolbox/attacks_v1/iterative_gradient.py b/foolbox/v1/attacks/iterative_gradient.py similarity index 100% rename from foolbox/attacks_v1/iterative_gradient.py rename to foolbox/v1/attacks/iterative_gradient.py diff --git a/foolbox/attacks_v1/iterative_projected_gradient.py b/foolbox/v1/attacks/iterative_projected_gradient.py similarity index 100% rename from foolbox/attacks_v1/iterative_projected_gradient.py rename to foolbox/v1/attacks/iterative_projected_gradient.py diff --git a/foolbox/attacks_v1/lbfgs.py b/foolbox/v1/attacks/lbfgs.py similarity index 100% rename from foolbox/attacks_v1/lbfgs.py rename to foolbox/v1/attacks/lbfgs.py diff --git a/foolbox/attacks_v1/localsearch.py b/foolbox/v1/attacks/localsearch.py similarity index 100% rename from foolbox/attacks_v1/localsearch.py rename to foolbox/v1/attacks/localsearch.py diff --git a/foolbox/attacks_v1/newtonfool.py b/foolbox/v1/attacks/newtonfool.py similarity index 100% rename from foolbox/attacks_v1/newtonfool.py rename to foolbox/v1/attacks/newtonfool.py diff --git a/foolbox/attacks_v1/pointwise.py b/foolbox/v1/attacks/pointwise.py similarity index 100% rename from foolbox/attacks_v1/pointwise.py rename to foolbox/v1/attacks/pointwise.py diff --git a/foolbox/attacks_v1/precomputed.py b/foolbox/v1/attacks/precomputed.py similarity index 100% rename from foolbox/attacks_v1/precomputed.py rename to foolbox/v1/attacks/precomputed.py diff --git a/foolbox/attacks_v1/saliency.py b/foolbox/v1/attacks/saliency.py similarity index 100% rename from foolbox/attacks_v1/saliency.py rename to foolbox/v1/attacks/saliency.py diff --git a/foolbox/attacks_v1/saltandpepper.py b/foolbox/v1/attacks/saltandpepper.py similarity index 100% rename from foolbox/attacks_v1/saltandpepper.py rename to foolbox/v1/attacks/saltandpepper.py diff --git a/foolbox/attacks_v1/slsqp.py b/foolbox/v1/attacks/slsqp.py similarity index 100% rename from foolbox/attacks_v1/slsqp.py rename to foolbox/v1/attacks/slsqp.py diff --git a/foolbox/attacks_v1/sparsefool.py b/foolbox/v1/attacks/sparsefool.py similarity index 100% rename from foolbox/attacks_v1/sparsefool.py rename to foolbox/v1/attacks/sparsefool.py diff --git a/foolbox/attacks_v1/spatial.py b/foolbox/v1/attacks/spatial.py similarity index 100% rename from foolbox/attacks_v1/spatial.py rename to foolbox/v1/attacks/spatial.py From f928e83c5fb45da07276cee8778a2353da4a4da0 Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 09:38:33 +0200 Subject: [PATCH 05/25] moved adversarial.py to v1 --- foolbox/{ => v1}/adversarial.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename foolbox/{ => v1}/adversarial.py (100%) diff --git a/foolbox/adversarial.py b/foolbox/v1/adversarial.py similarity index 100% rename from foolbox/adversarial.py rename to foolbox/v1/adversarial.py From 972f29f3efeecdca746af1719f1d411c44ee9337 Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 09:39:00 +0200 Subject: [PATCH 06/25] renamed yielding_adversarial.py to adversarial.py --- foolbox/{yielding_adversarial.py => adversarial.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename foolbox/{yielding_adversarial.py => adversarial.py} (100%) diff --git a/foolbox/yielding_adversarial.py b/foolbox/adversarial.py similarity index 100% rename from foolbox/yielding_adversarial.py rename to foolbox/adversarial.py From a07db080ff67bed3ccdfbbbc5f81a1499419cdbb Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 09:45:10 +0200 Subject: [PATCH 07/25] updated __init__ files --- foolbox/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/foolbox/__init__.py b/foolbox/__init__.py index f30f1588..a7a9699a 100755 --- a/foolbox/__init__.py +++ b/foolbox/__init__.py @@ -11,12 +11,11 @@ from . import criteria # noqa: F401 from . import distances # noqa: F401 from . import attacks # noqa: F401 -from . import attacks_v1 # noqa: F401 +from . import v1 # noqa: F401 from . import utils # noqa: F401 from . import gradient_estimators # noqa: F401 from .adversarial import Adversarial # noqa: F401 -from .yielding_adversarial import YieldingAdversarial # noqa: F401 from .batching import run_parallel # noqa: F401 from .batching import run_sequential # noqa: F401 From ebb7849355128f300cfee85c02c294126c8a3ee2 Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 09:45:27 +0200 Subject: [PATCH 08/25] added v1 module --- foolbox/v1/__init__.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 foolbox/v1/__init__.py diff --git a/foolbox/v1/__init__.py b/foolbox/v1/__init__.py new file mode 100644 index 00000000..7f92e4e7 --- /dev/null +++ b/foolbox/v1/__init__.py @@ -0,0 +1,2 @@ +from . import attacks # noqa: F401 +from .adversarial import Adversarial # noqa: F401 From ed1d33df4d85a07a2d585a8e7062e966e04e33f1 Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 09:47:14 +0200 Subject: [PATCH 09/25] updated batching.py --- foolbox/batching.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/foolbox/batching.py b/foolbox/batching.py index b7678009..204c7e3e 100644 --- a/foolbox/batching.py +++ b/foolbox/batching.py @@ -2,7 +2,7 @@ import numpy as np import itertools from .distances import MSE -from .yielding_adversarial import YieldingAdversarial +from .adversarial import Adversarial def run_sequential( @@ -104,7 +104,7 @@ def run_sequential( individual_kwargs[i] = {**kwargs, **individual_kwargs[i]} advs = [ - YieldingAdversarial( + Adversarial( model, _criterion, x, @@ -241,7 +241,7 @@ def run_parallel( # noqa: C901 individual_kwargs[i] = {**kwargs, **individual_kwargs[i]} advs = [ - YieldingAdversarial( + Adversarial( model, _criterion, x, From 8bee7ae96f8c0a9111d25ed31761c1d996ec5c7f Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 09:48:39 +0200 Subject: [PATCH 10/25] renamed YieldingAdversarial to Adversarial and based it on v1 --- foolbox/adversarial.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/foolbox/adversarial.py b/foolbox/adversarial.py index c80d17e8..445ef46e 100644 --- a/foolbox/adversarial.py +++ b/foolbox/adversarial.py @@ -5,16 +5,16 @@ import numpy as np -from .adversarial import Adversarial -from .adversarial import StopAttack +from v1.adversarial import Adversarial as BaseAdversarial +from v1.adversarial import StopAttack -class YieldingAdversarial(Adversarial): +class Adversarial(BaseAdversarial): def _check_unperturbed(self): try: # for now, we use the non-yielding implementation in the super-class # TODO: add support for batching this first call as well - super(YieldingAdversarial, self).forward_one(self._Adversarial__unperturbed) + super(Adversarial, self).forward_one(self._Adversarial__unperturbed) except StopAttack: # if a threshold is specified and the unperturbed input is # misclassified, this can already cause a StopAttack From ef182144cbe6fa497b9d4d0fb93a19de79b5d9a5 Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 09:49:43 +0200 Subject: [PATCH 11/25] changed import to be relative --- foolbox/adversarial.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/foolbox/adversarial.py b/foolbox/adversarial.py index 445ef46e..ae753225 100644 --- a/foolbox/adversarial.py +++ b/foolbox/adversarial.py @@ -5,8 +5,8 @@ import numpy as np -from v1.adversarial import Adversarial as BaseAdversarial -from v1.adversarial import StopAttack +from .v1.adversarial import Adversarial as BaseAdversarial +from .v1.adversarial import StopAttack class Adversarial(BaseAdversarial): From 12827f0d320c0bad1389239b408522ffa09a7dfe Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 10:00:54 +0200 Subject: [PATCH 12/25] renamed BatchAttack to Attack --- foolbox/attacks/__init__.py | 2 +- foolbox/attacks/additive_noise.py | 4 ++-- foolbox/attacks/adef_attack.py | 4 ++-- foolbox/attacks/base.py | 8 ++++---- foolbox/attacks/binarization.py | 4 ++-- foolbox/attacks/blended_noise.py | 4 ++-- foolbox/attacks/blur.py | 4 ++-- foolbox/attacks/boundary_attack.py | 5 ++--- foolbox/attacks/carlini_wagner.py | 4 ++-- foolbox/attacks/contrast.py | 4 ++-- foolbox/attacks/decoupled_direction_norm.py | 4 ++-- foolbox/attacks/deepfool.py | 4 ++-- foolbox/attacks/ead.py | 4 ++-- foolbox/attacks/gen.py | 4 ++-- foolbox/attacks/gradient.py | 4 ++-- foolbox/attacks/hop_skip_jump_attack.py | 4 ++-- foolbox/attacks/inversion.py | 4 ++-- foolbox/attacks/iterative_gradient.py | 4 ++-- foolbox/attacks/iterative_projected_gradient.py | 4 ++-- foolbox/attacks/localsearch.py | 6 +++--- foolbox/attacks/newtonfool.py | 4 ++-- foolbox/attacks/pointwise.py | 6 +++--- foolbox/attacks/precomputed.py | 4 ++-- foolbox/attacks/saliency.py | 4 ++-- foolbox/attacks/saltandpepper.py | 4 ++-- foolbox/attacks/spatial.py | 4 ++-- foolbox/attacks/virtual_adversarial.py | 4 ++-- 27 files changed, 57 insertions(+), 58 deletions(-) diff --git a/foolbox/attacks/__init__.py b/foolbox/attacks/__init__.py index 069e36ef..1edd1487 100644 --- a/foolbox/attacks/__init__.py +++ b/foolbox/attacks/__init__.py @@ -1,6 +1,6 @@ # flake8: noqa -from .base import BatchAttack +from .base import Attack from .gradient import GradientAttack, GradientSignAttack, FGSM from .iterative_gradient import IterativeGradientAttack, IterativeGradientSignAttack from .deepfool import DeepFoolAttack, DeepFoolL2Attack, DeepFoolLinfinityAttack diff --git a/foolbox/attacks/additive_noise.py b/foolbox/attacks/additive_noise.py index 01d1e34c..a39d4de5 100644 --- a/foolbox/attacks/additive_noise.py +++ b/foolbox/attacks/additive_noise.py @@ -3,12 +3,12 @@ import numpy as np -from .base import BatchAttack +from .base import Attack from .base import generator_decorator from .. import nprng -class AdditiveNoiseAttack(BatchAttack): +class AdditiveNoiseAttack(Attack): """Base class for attacks that add random noise to an input. """ diff --git a/foolbox/attacks/adef_attack.py b/foolbox/attacks/adef_attack.py index 1a12a986..ccb2aad5 100644 --- a/foolbox/attacks/adef_attack.py +++ b/foolbox/attacks/adef_attack.py @@ -4,7 +4,7 @@ from scipy.ndimage.filters import gaussian_filter import numpy as np -from .base import BatchAttack +from .base import Attack from .base import generator_decorator @@ -162,7 +162,7 @@ def _create_vec_field(fval, gradf, d1x, d2x, color_axis, smooth=0): return vec_field -class ADefAttack(BatchAttack): +class ADefAttack(Attack): """Adversarial attack that distorts the image, i.e. changes the locations of pixels. The algorithm is described in [1]_, a Repository with the original code can be found in [2]_. diff --git a/foolbox/attacks/base.py b/foolbox/attacks/base.py index ed317d04..750987ec 100644 --- a/foolbox/attacks/base.py +++ b/foolbox/attacks/base.py @@ -3,13 +3,13 @@ import functools import numpy as np -from ..attacks.base import Attack -from ..yielding_adversarial import YieldingAdversarial +from ..v1.attacks.base import Attack as BaseAttack +from ..advesarial import Adversarial from ..adversarial import StopAttack from ..batching import run_parallel -class BatchAttack(Attack): +class Attack(BaseAttack): def __call__(self, inputs, labels, unpack=True, individual_kwargs=None, **kwargs): assert isinstance(inputs, np.ndarray) assert isinstance(labels, np.ndarray) @@ -55,7 +55,7 @@ def __call__(self, inputs, labels, unpack=True, individual_kwargs=None, **kwargs def generator_decorator(generator): @functools.wraps(generator) def wrapper(self, a, **kwargs): - assert isinstance(a, YieldingAdversarial) + assert isinstance(a, Adversarial) if a.distance.value == 0.0: logging.info( diff --git a/foolbox/attacks/binarization.py b/foolbox/attacks/binarization.py index 370b9d18..5e3f68f5 100644 --- a/foolbox/attacks/binarization.py +++ b/foolbox/attacks/binarization.py @@ -3,11 +3,11 @@ import numpy as np -from .base import BatchAttack +from .base import Attack from .base import generator_decorator -class BinarizationRefinementAttack(BatchAttack): +class BinarizationRefinementAttack(Attack): """For models that preprocess their inputs by binarizing the inputs, this attack can improve adversarials found by other attacks. It does os by utilizing information about the diff --git a/foolbox/attacks/blended_noise.py b/foolbox/attacks/blended_noise.py index 88546da9..b8b8cfc1 100644 --- a/foolbox/attacks/blended_noise.py +++ b/foolbox/attacks/blended_noise.py @@ -4,12 +4,12 @@ import numpy as np -from .base import BatchAttack +from .base import Attack from .base import generator_decorator from .. import nprng -class BlendedUniformNoiseAttack(BatchAttack): +class BlendedUniformNoiseAttack(Attack): """Blends the input with a uniform noise input until it is misclassified. """ diff --git a/foolbox/attacks/blur.py b/foolbox/attacks/blur.py index 1714137e..925fedc5 100644 --- a/foolbox/attacks/blur.py +++ b/foolbox/attacks/blur.py @@ -3,11 +3,11 @@ from scipy.ndimage.filters import gaussian_filter -from .base import BatchAttack +from .base import Attack from .base import generator_decorator -class GaussianBlurAttack(BatchAttack): +class GaussianBlurAttack(Attack): """Blurs the input until it is misclassified.""" @generator_decorator diff --git a/foolbox/attacks/boundary_attack.py b/foolbox/attacks/boundary_attack.py index ac7154c2..231f72e9 100644 --- a/foolbox/attacks/boundary_attack.py +++ b/foolbox/attacks/boundary_attack.py @@ -9,7 +9,6 @@ from concurrent.futures import Executor from concurrent.futures import Future -from .base import BatchAttack from .base import Attack from .base import generator_decorator from .blended_noise import BlendedUniformNoiseAttack @@ -18,7 +17,7 @@ from numpy.linalg import norm -class BoundaryAttack(BatchAttack): +class BoundaryAttack(Attack): """A powerful adversarial attack that requires neither gradients nor probabilities. @@ -662,7 +661,7 @@ def initialize_starting_point(self, a): " Falling back to {} for initialization.".format(init_attack.__name__) ) - if issubclass(init_attack, Attack) or issubclass(init_attack, BatchAttack): + if issubclass(init_attack, Attack): # instantiate if necessary init_attack = init_attack() diff --git a/foolbox/attacks/carlini_wagner.py b/foolbox/attacks/carlini_wagner.py index a774e889..3a718781 100644 --- a/foolbox/attacks/carlini_wagner.py +++ b/foolbox/attacks/carlini_wagner.py @@ -1,12 +1,12 @@ import numpy as np import logging -from .base import BatchAttack +from .base import Attack from .base import generator_decorator from ..utils import onehot_like -class CarliniWagnerL2Attack(BatchAttack): +class CarliniWagnerL2Attack(Attack): """The L2 version of the Carlini & Wagner attack. This attack is described in [1]_. This implementation diff --git a/foolbox/attacks/contrast.py b/foolbox/attacks/contrast.py index 6beeccaf..fd0a6f7e 100644 --- a/foolbox/attacks/contrast.py +++ b/foolbox/attacks/contrast.py @@ -1,11 +1,11 @@ import numpy as np from collections import Iterable -from .base import BatchAttack +from .base import Attack from .base import generator_decorator -class ContrastReductionAttack(BatchAttack): +class ContrastReductionAttack(Attack): """Reduces the contrast of the input until it is misclassified.""" @generator_decorator diff --git a/foolbox/attacks/decoupled_direction_norm.py b/foolbox/attacks/decoupled_direction_norm.py index 346e2246..1e6147b5 100644 --- a/foolbox/attacks/decoupled_direction_norm.py +++ b/foolbox/attacks/decoupled_direction_norm.py @@ -2,11 +2,11 @@ import numpy as np import logging -from .base import BatchAttack +from .base import Attack from .base import generator_decorator -class DecoupledDirectionNormL2Attack(BatchAttack): +class DecoupledDirectionNormL2Attack(Attack): """The Decoupled Direction and Norm L2 adversarial attack from [1]_. References diff --git a/foolbox/attacks/deepfool.py b/foolbox/attacks/deepfool.py index d86019f9..238fa578 100644 --- a/foolbox/attacks/deepfool.py +++ b/foolbox/attacks/deepfool.py @@ -2,14 +2,14 @@ import numpy as np -from .base import BatchAttack +from .base import Attack from .base import generator_decorator from ..utils import crossentropy from ..distances import MeanSquaredDistance from ..distances import Linfinity -class DeepFoolAttack(BatchAttack): +class DeepFoolAttack(Attack): """Simple and close to optimal gradient-based adversarial attack. diff --git a/foolbox/attacks/ead.py b/foolbox/attacks/ead.py index 38dcbd3d..932d3390 100644 --- a/foolbox/attacks/ead.py +++ b/foolbox/attacks/ead.py @@ -1,12 +1,12 @@ import numpy as np import logging -from .base import BatchAttack +from .base import Attack from .base import generator_decorator from ..utils import onehot_like -class EADAttack(BatchAttack): +class EADAttack(Attack): """Gradient based attack which uses an elastic-net regularization [1]. This implementation is based on the attacks description [1] and its reference implementation [2]. diff --git a/foolbox/attacks/gen.py b/foolbox/attacks/gen.py index f01a68cf..10813f0a 100644 --- a/foolbox/attacks/gen.py +++ b/foolbox/attacks/gen.py @@ -3,12 +3,12 @@ import logging from scipy.ndimage import zoom -from .base import BatchAttack +from .base import Attack from .base import generator_decorator from ..utils import softmax -class GenAttack(BatchAttack): +class GenAttack(Attack): """The GenAttack introduced in [1]_. This attack is performs a genetic search in order to find an adversarial diff --git a/foolbox/attacks/gradient.py b/foolbox/attacks/gradient.py index a98c9294..3bf41d91 100644 --- a/foolbox/attacks/gradient.py +++ b/foolbox/attacks/gradient.py @@ -3,11 +3,11 @@ import logging import abc -from .base import BatchAttack +from .base import Attack from .base import generator_decorator -class SingleStepGradientBaseAttack(BatchAttack): +class SingleStepGradientBaseAttack(Attack): """Common base class for single step gradient attacks.""" @abc.abstractmethod diff --git a/foolbox/attacks/hop_skip_jump_attack.py b/foolbox/attacks/hop_skip_jump_attack.py index d8205e93..d7ee3c20 100644 --- a/foolbox/attacks/hop_skip_jump_attack.py +++ b/foolbox/attacks/hop_skip_jump_attack.py @@ -2,7 +2,7 @@ import time import sys -from .base import BatchAttack +from .base import Attack from .base import generator_decorator from ..distances import MSE, Linf from ..criteria import Misclassification @@ -12,7 +12,7 @@ import logging -class HopSkipJumpAttack(BatchAttack): +class HopSkipJumpAttack(Attack): """A powerful adversarial attack that requires neither gradients nor probabilities. diff --git a/foolbox/attacks/inversion.py b/foolbox/attacks/inversion.py index 9fabbbd5..04866557 100644 --- a/foolbox/attacks/inversion.py +++ b/foolbox/attacks/inversion.py @@ -1,8 +1,8 @@ -from .base import BatchAttack +from .base import Attack from .base import generator_decorator -class InversionAttack(BatchAttack): +class InversionAttack(Attack): """Creates "negative images" by inverting the pixel values according to [1]_. diff --git a/foolbox/attacks/iterative_gradient.py b/foolbox/attacks/iterative_gradient.py index 683880e1..f440a2fa 100644 --- a/foolbox/attacks/iterative_gradient.py +++ b/foolbox/attacks/iterative_gradient.py @@ -3,11 +3,11 @@ import abc import logging -from .base import BatchAttack +from .base import Attack from .base import generator_decorator -class IterativeGradientBaseAttack(BatchAttack): +class IterativeGradientBaseAttack(Attack): """Common base class for iterative gradient attacks.""" @abc.abstractmethod diff --git a/foolbox/attacks/iterative_projected_gradient.py b/foolbox/attacks/iterative_projected_gradient.py index 96bd5689..81c0b5f2 100644 --- a/foolbox/attacks/iterative_projected_gradient.py +++ b/foolbox/attacks/iterative_projected_gradient.py @@ -3,7 +3,7 @@ import logging import warnings -from .base import BatchAttack +from .base import Attack from .base import generator_decorator from .. import distances from ..utils import crossentropy @@ -12,7 +12,7 @@ from ..optimizers import GDOptimizer -class IterativeProjectedGradientBaseAttack(BatchAttack): +class IterativeProjectedGradientBaseAttack(Attack): """Base class for iterative (projected) gradient attacks. Concrete subclasses should implement as_generator, _gradient diff --git a/foolbox/attacks/localsearch.py b/foolbox/attacks/localsearch.py index faea5df1..f0d9b890 100644 --- a/foolbox/attacks/localsearch.py +++ b/foolbox/attacks/localsearch.py @@ -1,11 +1,11 @@ -from .base import BatchAttack +from .base import Attack from .base import generator_decorator import numpy as np from .. import nprng from ..utils import softmax -class SinglePixelAttack(BatchAttack): +class SinglePixelAttack(Attack): """Perturbs just a single pixel and sets it to the min or max.""" @generator_decorator @@ -58,7 +58,7 @@ def as_generator(self, a, max_pixels=1000): return -class LocalSearchAttack(BatchAttack): +class LocalSearchAttack(Attack): """A black-box attack based on the idea of greedy local search. This implementation is based on the algorithm in [1]_. diff --git a/foolbox/attacks/newtonfool.py b/foolbox/attacks/newtonfool.py index d790a659..ba92e56d 100644 --- a/foolbox/attacks/newtonfool.py +++ b/foolbox/attacks/newtonfool.py @@ -1,13 +1,13 @@ import logging -from .base import BatchAttack +from .base import Attack from .base import generator_decorator from ..utils import softmax import numpy as np -class NewtonFoolAttack(BatchAttack): +class NewtonFoolAttack(Attack): """Implements the NewtonFool Attack. The attack was introduced in [1]_. diff --git a/foolbox/attacks/pointwise.py b/foolbox/attacks/pointwise.py index 7fb31d1b..47ed3271 100644 --- a/foolbox/attacks/pointwise.py +++ b/foolbox/attacks/pointwise.py @@ -1,14 +1,14 @@ import warnings import logging -from .base import BatchAttack +from .base import Attack from .base import Attack from .base import generator_decorator from .saltandpepper import SaltAndPepperNoiseAttack from .. import rng -class PointwiseAttack(BatchAttack): +class PointwiseAttack(Attack): """Starts with an adversarial and performs a binary search between the adversarial and the original for each dimension of the input individually. @@ -199,7 +199,7 @@ def initialize_starting_point(self, a): " Falling back to {} for initialization.".format(init_attack.__name__) ) - if issubclass(init_attack, Attack) or issubclass(init_attack, BatchAttack): + if issubclass(init_attack, Attack) or issubclass(init_attack, Attack): # instantiate if necessary init_attack = init_attack() diff --git a/foolbox/attacks/precomputed.py b/foolbox/attacks/precomputed.py index 3fb42038..f8536632 100644 --- a/foolbox/attacks/precomputed.py +++ b/foolbox/attacks/precomputed.py @@ -1,10 +1,10 @@ import numpy as np -from .base import BatchAttack +from .base import Attack from .base import generator_decorator -class PrecomputedAdversarialsAttack(BatchAttack): +class PrecomputedAdversarialsAttack(Attack): """Attacks a model using precomputed adversarial candidates.""" def _get_output(self, a, x, inputs, outputs): diff --git a/foolbox/attacks/saliency.py b/foolbox/attacks/saliency.py index 2fce4144..506822da 100644 --- a/foolbox/attacks/saliency.py +++ b/foolbox/attacks/saliency.py @@ -2,13 +2,13 @@ import numpy as np -from .base import BatchAttack +from .base import Attack from .base import generator_decorator from .gradient import GradientAttack from .. import rng -class SaliencyMapAttack(BatchAttack): +class SaliencyMapAttack(Attack): """Implements the Saliency Map Attack. The attack was introduced in [1]_. diff --git a/foolbox/attacks/saltandpepper.py b/foolbox/attacks/saltandpepper.py index d8d8afc8..8367b223 100644 --- a/foolbox/attacks/saltandpepper.py +++ b/foolbox/attacks/saltandpepper.py @@ -1,11 +1,11 @@ import numpy as np -from .base import BatchAttack +from .base import Attack from .base import generator_decorator from .. import nprng -class SaltAndPepperNoiseAttack(BatchAttack): +class SaltAndPepperNoiseAttack(Attack): """Increases the amount of salt and pepper noise until the input is misclassified. """ diff --git a/foolbox/attacks/spatial.py b/foolbox/attacks/spatial.py index 64ec3b24..4adbb5f1 100644 --- a/foolbox/attacks/spatial.py +++ b/foolbox/attacks/spatial.py @@ -3,12 +3,12 @@ from scipy.ndimage import rotate, shift import operator -from .base import BatchAttack +from .base import Attack from .base import generator_decorator from .. import nprng -class SpatialAttack(BatchAttack): +class SpatialAttack(Attack): """Adversarially chosen rotations and translations [1]. This implementation is based on the reference implementation by diff --git a/foolbox/attacks/virtual_adversarial.py b/foolbox/attacks/virtual_adversarial.py index 0b650516..6a01731b 100644 --- a/foolbox/attacks/virtual_adversarial.py +++ b/foolbox/attacks/virtual_adversarial.py @@ -2,12 +2,12 @@ from collections import Iterable import logging -from .base import BatchAttack +from .base import Attack from .base import generator_decorator from ..utils import softmax -class VirtualAdversarialAttack(BatchAttack): +class VirtualAdversarialAttack(Attack): """Calculate an untargeted adversarial perturbation by performing a approximated second order optimization step on the KL divergence between the unperturbed predictions and the predictions for the adversarial From d797325ac3578fc626d1171c22a66656376446e8 Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 10:05:39 +0200 Subject: [PATCH 13/25] fixed import --- foolbox/v1/attacks/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foolbox/v1/attacks/base.py b/foolbox/v1/attacks/base.py index 431d0a59..555b8a4a 100644 --- a/foolbox/v1/attacks/base.py +++ b/foolbox/v1/attacks/base.py @@ -5,7 +5,7 @@ from abc import abstractmethod from ..adversarial import Adversarial -from ..yielding_adversarial import YieldingAdversarial +from ...adversarial import Adversarial as YieldingAdversarial from ..adversarial import StopAttack from ..criteria import Misclassification from ..distances import MSE From 5311344d8a28de997dbfd04b7aaf3be6121c1384 Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 10:07:33 +0200 Subject: [PATCH 14/25] changed conftest to use v1.Adversarial for now --- foolbox/tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foolbox/tests/conftest.py b/foolbox/tests/conftest.py index 16c4fe19..a912b579 100644 --- a/foolbox/tests/conftest.py +++ b/foolbox/tests/conftest.py @@ -29,7 +29,7 @@ from foolbox.models import CaffeModel from foolbox.models import ModelWithoutGradients from foolbox.models import ModelWithEstimatedGradients -from foolbox import Adversarial +from foolbox.v1 import Adversarial from foolbox.distances import MSE from foolbox.distances import Linfinity from foolbox.distances import MAE From 99e9c96765f94574eb8712f8befde12f9719a695 Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 10:08:48 +0200 Subject: [PATCH 15/25] moved tests/attacks to tests/v1/attacks --- foolbox/tests/{ => v1}/attacks/__init__.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_adef_attack.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_approx_lbfgs.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_binarization.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_blur.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_boundary.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_carlini_wagner.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_contrast.py | 0 .../{ => v1}/attacks/test_attacks_decoupled_direction_norm.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_deepfool.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_ead.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_gradient.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_gradient_sign.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_hsja.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_iterative_gradient.py | 0 .../{ => v1}/attacks/test_attacks_iterative_gradient_sign.py | 0 .../{ => v1}/attacks/test_attacks_iterative_projected_gradient.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_lbfgs.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_localsearch.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_newtonfool.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_noise.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_pointwise.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_precomputed.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_saliency.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_singlepixel.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_slsqp.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_sparsefool.py | 0 foolbox/tests/{ => v1}/attacks/test_attacks_spatial.py | 0 28 files changed, 0 insertions(+), 0 deletions(-) rename foolbox/tests/{ => v1}/attacks/__init__.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_adef_attack.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_approx_lbfgs.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_binarization.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_blur.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_boundary.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_carlini_wagner.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_contrast.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_decoupled_direction_norm.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_deepfool.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_ead.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_gradient.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_gradient_sign.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_hsja.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_iterative_gradient.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_iterative_gradient_sign.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_iterative_projected_gradient.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_lbfgs.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_localsearch.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_newtonfool.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_noise.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_pointwise.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_precomputed.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_saliency.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_singlepixel.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_slsqp.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_sparsefool.py (100%) rename foolbox/tests/{ => v1}/attacks/test_attacks_spatial.py (100%) diff --git a/foolbox/tests/attacks/__init__.py b/foolbox/tests/v1/attacks/__init__.py similarity index 100% rename from foolbox/tests/attacks/__init__.py rename to foolbox/tests/v1/attacks/__init__.py diff --git a/foolbox/tests/attacks/test_attacks_adef_attack.py b/foolbox/tests/v1/attacks/test_attacks_adef_attack.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_adef_attack.py rename to foolbox/tests/v1/attacks/test_attacks_adef_attack.py diff --git a/foolbox/tests/attacks/test_attacks_approx_lbfgs.py b/foolbox/tests/v1/attacks/test_attacks_approx_lbfgs.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_approx_lbfgs.py rename to foolbox/tests/v1/attacks/test_attacks_approx_lbfgs.py diff --git a/foolbox/tests/attacks/test_attacks_binarization.py b/foolbox/tests/v1/attacks/test_attacks_binarization.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_binarization.py rename to foolbox/tests/v1/attacks/test_attacks_binarization.py diff --git a/foolbox/tests/attacks/test_attacks_blur.py b/foolbox/tests/v1/attacks/test_attacks_blur.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_blur.py rename to foolbox/tests/v1/attacks/test_attacks_blur.py diff --git a/foolbox/tests/attacks/test_attacks_boundary.py b/foolbox/tests/v1/attacks/test_attacks_boundary.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_boundary.py rename to foolbox/tests/v1/attacks/test_attacks_boundary.py diff --git a/foolbox/tests/attacks/test_attacks_carlini_wagner.py b/foolbox/tests/v1/attacks/test_attacks_carlini_wagner.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_carlini_wagner.py rename to foolbox/tests/v1/attacks/test_attacks_carlini_wagner.py diff --git a/foolbox/tests/attacks/test_attacks_contrast.py b/foolbox/tests/v1/attacks/test_attacks_contrast.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_contrast.py rename to foolbox/tests/v1/attacks/test_attacks_contrast.py diff --git a/foolbox/tests/attacks/test_attacks_decoupled_direction_norm.py b/foolbox/tests/v1/attacks/test_attacks_decoupled_direction_norm.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_decoupled_direction_norm.py rename to foolbox/tests/v1/attacks/test_attacks_decoupled_direction_norm.py diff --git a/foolbox/tests/attacks/test_attacks_deepfool.py b/foolbox/tests/v1/attacks/test_attacks_deepfool.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_deepfool.py rename to foolbox/tests/v1/attacks/test_attacks_deepfool.py diff --git a/foolbox/tests/attacks/test_attacks_ead.py b/foolbox/tests/v1/attacks/test_attacks_ead.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_ead.py rename to foolbox/tests/v1/attacks/test_attacks_ead.py diff --git a/foolbox/tests/attacks/test_attacks_gradient.py b/foolbox/tests/v1/attacks/test_attacks_gradient.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_gradient.py rename to foolbox/tests/v1/attacks/test_attacks_gradient.py diff --git a/foolbox/tests/attacks/test_attacks_gradient_sign.py b/foolbox/tests/v1/attacks/test_attacks_gradient_sign.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_gradient_sign.py rename to foolbox/tests/v1/attacks/test_attacks_gradient_sign.py diff --git a/foolbox/tests/attacks/test_attacks_hsja.py b/foolbox/tests/v1/attacks/test_attacks_hsja.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_hsja.py rename to foolbox/tests/v1/attacks/test_attacks_hsja.py diff --git a/foolbox/tests/attacks/test_attacks_iterative_gradient.py b/foolbox/tests/v1/attacks/test_attacks_iterative_gradient.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_iterative_gradient.py rename to foolbox/tests/v1/attacks/test_attacks_iterative_gradient.py diff --git a/foolbox/tests/attacks/test_attacks_iterative_gradient_sign.py b/foolbox/tests/v1/attacks/test_attacks_iterative_gradient_sign.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_iterative_gradient_sign.py rename to foolbox/tests/v1/attacks/test_attacks_iterative_gradient_sign.py diff --git a/foolbox/tests/attacks/test_attacks_iterative_projected_gradient.py b/foolbox/tests/v1/attacks/test_attacks_iterative_projected_gradient.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_iterative_projected_gradient.py rename to foolbox/tests/v1/attacks/test_attacks_iterative_projected_gradient.py diff --git a/foolbox/tests/attacks/test_attacks_lbfgs.py b/foolbox/tests/v1/attacks/test_attacks_lbfgs.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_lbfgs.py rename to foolbox/tests/v1/attacks/test_attacks_lbfgs.py diff --git a/foolbox/tests/attacks/test_attacks_localsearch.py b/foolbox/tests/v1/attacks/test_attacks_localsearch.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_localsearch.py rename to foolbox/tests/v1/attacks/test_attacks_localsearch.py diff --git a/foolbox/tests/attacks/test_attacks_newtonfool.py b/foolbox/tests/v1/attacks/test_attacks_newtonfool.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_newtonfool.py rename to foolbox/tests/v1/attacks/test_attacks_newtonfool.py diff --git a/foolbox/tests/attacks/test_attacks_noise.py b/foolbox/tests/v1/attacks/test_attacks_noise.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_noise.py rename to foolbox/tests/v1/attacks/test_attacks_noise.py diff --git a/foolbox/tests/attacks/test_attacks_pointwise.py b/foolbox/tests/v1/attacks/test_attacks_pointwise.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_pointwise.py rename to foolbox/tests/v1/attacks/test_attacks_pointwise.py diff --git a/foolbox/tests/attacks/test_attacks_precomputed.py b/foolbox/tests/v1/attacks/test_attacks_precomputed.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_precomputed.py rename to foolbox/tests/v1/attacks/test_attacks_precomputed.py diff --git a/foolbox/tests/attacks/test_attacks_saliency.py b/foolbox/tests/v1/attacks/test_attacks_saliency.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_saliency.py rename to foolbox/tests/v1/attacks/test_attacks_saliency.py diff --git a/foolbox/tests/attacks/test_attacks_singlepixel.py b/foolbox/tests/v1/attacks/test_attacks_singlepixel.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_singlepixel.py rename to foolbox/tests/v1/attacks/test_attacks_singlepixel.py diff --git a/foolbox/tests/attacks/test_attacks_slsqp.py b/foolbox/tests/v1/attacks/test_attacks_slsqp.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_slsqp.py rename to foolbox/tests/v1/attacks/test_attacks_slsqp.py diff --git a/foolbox/tests/attacks/test_attacks_sparsefool.py b/foolbox/tests/v1/attacks/test_attacks_sparsefool.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_sparsefool.py rename to foolbox/tests/v1/attacks/test_attacks_sparsefool.py diff --git a/foolbox/tests/attacks/test_attacks_spatial.py b/foolbox/tests/v1/attacks/test_attacks_spatial.py similarity index 100% rename from foolbox/tests/attacks/test_attacks_spatial.py rename to foolbox/tests/v1/attacks/test_attacks_spatial.py From de00db67e9163ee286c3cebcc51425a2093e6de8 Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 10:09:08 +0200 Subject: [PATCH 16/25] moved tests/batch_attacks to tests/attacks --- foolbox/tests/{batch_attacks => attacks}/__init__.py | 0 .../{batch_attacks => attacks}/test_batch_attacks_adef_attack.py | 0 .../{batch_attacks => attacks}/test_batch_attacks_binarization.py | 0 .../tests/{batch_attacks => attacks}/test_batch_attacks_blur.py | 0 .../{batch_attacks => attacks}/test_batch_attacks_boundary.py | 0 .../{batch_attacks => attacks}/test_batch_attacks_contrast.py | 0 .../test_batch_attacks_decoupled_direction_norm.py | 0 .../{batch_attacks => attacks}/test_batch_attacks_deepfool.py | 0 .../tests/{batch_attacks => attacks}/test_batch_attacks_hsja.py | 0 .../{batch_attacks => attacks}/test_batch_attacks_inversion.py | 0 .../test_batch_attacks_iterative_gradient.py | 0 .../test_batch_attacks_iterative_gradient_sign.py | 0 .../{batch_attacks => attacks}/test_batch_attacks_localsearch.py | 0 .../{batch_attacks => attacks}/test_batch_attacks_newtonfool.py | 0 .../tests/{batch_attacks => attacks}/test_batch_attacks_noise.py | 0 .../{batch_attacks => attacks}/test_batch_attacks_pointwise.py | 0 .../{batch_attacks => attacks}/test_batch_attacks_precomputed.py | 0 .../{batch_attacks => attacks}/test_batch_attacks_saliency.py | 0 .../{batch_attacks => attacks}/test_batch_attacks_singlepixel.py | 0 .../{batch_attacks => attacks}/test_batch_attacks_spatial.py | 0 .../tests/{batch_attacks => attacks}/test_batch_carlini_wagner.py | 0 foolbox/tests/{batch_attacks => attacks}/test_batch_ead.py | 0 foolbox/tests/{batch_attacks => attacks}/test_batch_gen.py | 0 foolbox/tests/{batch_attacks => attacks}/test_batch_gradient.py | 0 .../tests/{batch_attacks => attacks}/test_batch_gradient_sign.py | 0 .../test_batch_iterative_projected_gradient.py | 0 .../{batch_attacks => attacks}/test_batch_virtual_adversarial.py | 0 27 files changed, 0 insertions(+), 0 deletions(-) rename foolbox/tests/{batch_attacks => attacks}/__init__.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_attacks_adef_attack.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_attacks_binarization.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_attacks_blur.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_attacks_boundary.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_attacks_contrast.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_attacks_decoupled_direction_norm.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_attacks_deepfool.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_attacks_hsja.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_attacks_inversion.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_attacks_iterative_gradient.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_attacks_iterative_gradient_sign.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_attacks_localsearch.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_attacks_newtonfool.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_attacks_noise.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_attacks_pointwise.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_attacks_precomputed.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_attacks_saliency.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_attacks_singlepixel.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_attacks_spatial.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_carlini_wagner.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_ead.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_gen.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_gradient.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_gradient_sign.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_iterative_projected_gradient.py (100%) rename foolbox/tests/{batch_attacks => attacks}/test_batch_virtual_adversarial.py (100%) diff --git a/foolbox/tests/batch_attacks/__init__.py b/foolbox/tests/attacks/__init__.py similarity index 100% rename from foolbox/tests/batch_attacks/__init__.py rename to foolbox/tests/attacks/__init__.py diff --git a/foolbox/tests/batch_attacks/test_batch_attacks_adef_attack.py b/foolbox/tests/attacks/test_batch_attacks_adef_attack.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_attacks_adef_attack.py rename to foolbox/tests/attacks/test_batch_attacks_adef_attack.py diff --git a/foolbox/tests/batch_attacks/test_batch_attacks_binarization.py b/foolbox/tests/attacks/test_batch_attacks_binarization.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_attacks_binarization.py rename to foolbox/tests/attacks/test_batch_attacks_binarization.py diff --git a/foolbox/tests/batch_attacks/test_batch_attacks_blur.py b/foolbox/tests/attacks/test_batch_attacks_blur.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_attacks_blur.py rename to foolbox/tests/attacks/test_batch_attacks_blur.py diff --git a/foolbox/tests/batch_attacks/test_batch_attacks_boundary.py b/foolbox/tests/attacks/test_batch_attacks_boundary.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_attacks_boundary.py rename to foolbox/tests/attacks/test_batch_attacks_boundary.py diff --git a/foolbox/tests/batch_attacks/test_batch_attacks_contrast.py b/foolbox/tests/attacks/test_batch_attacks_contrast.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_attacks_contrast.py rename to foolbox/tests/attacks/test_batch_attacks_contrast.py diff --git a/foolbox/tests/batch_attacks/test_batch_attacks_decoupled_direction_norm.py b/foolbox/tests/attacks/test_batch_attacks_decoupled_direction_norm.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_attacks_decoupled_direction_norm.py rename to foolbox/tests/attacks/test_batch_attacks_decoupled_direction_norm.py diff --git a/foolbox/tests/batch_attacks/test_batch_attacks_deepfool.py b/foolbox/tests/attacks/test_batch_attacks_deepfool.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_attacks_deepfool.py rename to foolbox/tests/attacks/test_batch_attacks_deepfool.py diff --git a/foolbox/tests/batch_attacks/test_batch_attacks_hsja.py b/foolbox/tests/attacks/test_batch_attacks_hsja.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_attacks_hsja.py rename to foolbox/tests/attacks/test_batch_attacks_hsja.py diff --git a/foolbox/tests/batch_attacks/test_batch_attacks_inversion.py b/foolbox/tests/attacks/test_batch_attacks_inversion.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_attacks_inversion.py rename to foolbox/tests/attacks/test_batch_attacks_inversion.py diff --git a/foolbox/tests/batch_attacks/test_batch_attacks_iterative_gradient.py b/foolbox/tests/attacks/test_batch_attacks_iterative_gradient.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_attacks_iterative_gradient.py rename to foolbox/tests/attacks/test_batch_attacks_iterative_gradient.py diff --git a/foolbox/tests/batch_attacks/test_batch_attacks_iterative_gradient_sign.py b/foolbox/tests/attacks/test_batch_attacks_iterative_gradient_sign.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_attacks_iterative_gradient_sign.py rename to foolbox/tests/attacks/test_batch_attacks_iterative_gradient_sign.py diff --git a/foolbox/tests/batch_attacks/test_batch_attacks_localsearch.py b/foolbox/tests/attacks/test_batch_attacks_localsearch.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_attacks_localsearch.py rename to foolbox/tests/attacks/test_batch_attacks_localsearch.py diff --git a/foolbox/tests/batch_attacks/test_batch_attacks_newtonfool.py b/foolbox/tests/attacks/test_batch_attacks_newtonfool.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_attacks_newtonfool.py rename to foolbox/tests/attacks/test_batch_attacks_newtonfool.py diff --git a/foolbox/tests/batch_attacks/test_batch_attacks_noise.py b/foolbox/tests/attacks/test_batch_attacks_noise.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_attacks_noise.py rename to foolbox/tests/attacks/test_batch_attacks_noise.py diff --git a/foolbox/tests/batch_attacks/test_batch_attacks_pointwise.py b/foolbox/tests/attacks/test_batch_attacks_pointwise.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_attacks_pointwise.py rename to foolbox/tests/attacks/test_batch_attacks_pointwise.py diff --git a/foolbox/tests/batch_attacks/test_batch_attacks_precomputed.py b/foolbox/tests/attacks/test_batch_attacks_precomputed.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_attacks_precomputed.py rename to foolbox/tests/attacks/test_batch_attacks_precomputed.py diff --git a/foolbox/tests/batch_attacks/test_batch_attacks_saliency.py b/foolbox/tests/attacks/test_batch_attacks_saliency.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_attacks_saliency.py rename to foolbox/tests/attacks/test_batch_attacks_saliency.py diff --git a/foolbox/tests/batch_attacks/test_batch_attacks_singlepixel.py b/foolbox/tests/attacks/test_batch_attacks_singlepixel.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_attacks_singlepixel.py rename to foolbox/tests/attacks/test_batch_attacks_singlepixel.py diff --git a/foolbox/tests/batch_attacks/test_batch_attacks_spatial.py b/foolbox/tests/attacks/test_batch_attacks_spatial.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_attacks_spatial.py rename to foolbox/tests/attacks/test_batch_attacks_spatial.py diff --git a/foolbox/tests/batch_attacks/test_batch_carlini_wagner.py b/foolbox/tests/attacks/test_batch_carlini_wagner.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_carlini_wagner.py rename to foolbox/tests/attacks/test_batch_carlini_wagner.py diff --git a/foolbox/tests/batch_attacks/test_batch_ead.py b/foolbox/tests/attacks/test_batch_ead.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_ead.py rename to foolbox/tests/attacks/test_batch_ead.py diff --git a/foolbox/tests/batch_attacks/test_batch_gen.py b/foolbox/tests/attacks/test_batch_gen.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_gen.py rename to foolbox/tests/attacks/test_batch_gen.py diff --git a/foolbox/tests/batch_attacks/test_batch_gradient.py b/foolbox/tests/attacks/test_batch_gradient.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_gradient.py rename to foolbox/tests/attacks/test_batch_gradient.py diff --git a/foolbox/tests/batch_attacks/test_batch_gradient_sign.py b/foolbox/tests/attacks/test_batch_gradient_sign.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_gradient_sign.py rename to foolbox/tests/attacks/test_batch_gradient_sign.py diff --git a/foolbox/tests/batch_attacks/test_batch_iterative_projected_gradient.py b/foolbox/tests/attacks/test_batch_iterative_projected_gradient.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_iterative_projected_gradient.py rename to foolbox/tests/attacks/test_batch_iterative_projected_gradient.py diff --git a/foolbox/tests/batch_attacks/test_batch_virtual_adversarial.py b/foolbox/tests/attacks/test_batch_virtual_adversarial.py similarity index 100% rename from foolbox/tests/batch_attacks/test_batch_virtual_adversarial.py rename to foolbox/tests/attacks/test_batch_virtual_adversarial.py From dbb682edfa14feaa0eecddd0dec6e9d511635c07 Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 10:10:21 +0200 Subject: [PATCH 17/25] added tests/v1 module --- foolbox/tests/v1/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 foolbox/tests/v1/__init__.py diff --git a/foolbox/tests/v1/__init__.py b/foolbox/tests/v1/__init__.py new file mode 100644 index 00000000..e69de29b From 77fb71de95bc65100f6df63c1eb52b14ba2cb7ef Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 10:18:19 +0200 Subject: [PATCH 18/25] updated imports in tests --- foolbox/tests/test_adversarial.py | 6 ++--- .../v1/attacks/test_attacks_adef_attack.py | 2 +- .../v1/attacks/test_attacks_approx_lbfgs.py | 2 +- .../v1/attacks/test_attacks_binarization.py | 4 ++-- foolbox/tests/v1/attacks/test_attacks_blur.py | 2 +- .../tests/v1/attacks/test_attacks_boundary.py | 6 ++--- .../v1/attacks/test_attacks_carlini_wagner.py | 2 +- .../tests/v1/attacks/test_attacks_contrast.py | 2 +- .../test_attacks_decoupled_direction_norm.py | 2 +- .../tests/v1/attacks/test_attacks_deepfool.py | 6 ++--- foolbox/tests/v1/attacks/test_attacks_ead.py | 2 +- .../tests/v1/attacks/test_attacks_gradient.py | 2 +- .../v1/attacks/test_attacks_gradient_sign.py | 2 +- foolbox/tests/v1/attacks/test_attacks_hsja.py | 4 ++-- .../test_attacks_iterative_gradient.py | 2 +- .../test_attacks_iterative_gradient_sign.py | 2 +- ...st_attacks_iterative_projected_gradient.py | 22 +++++++++---------- .../tests/v1/attacks/test_attacks_lbfgs.py | 2 +- .../v1/attacks/test_attacks_localsearch.py | 2 +- .../v1/attacks/test_attacks_newtonfool.py | 2 +- .../tests/v1/attacks/test_attacks_noise.py | 8 +++---- .../v1/attacks/test_attacks_pointwise.py | 2 +- .../v1/attacks/test_attacks_precomputed.py | 2 +- .../tests/v1/attacks/test_attacks_saliency.py | 2 +- .../v1/attacks/test_attacks_singlepixel.py | 2 +- .../tests/v1/attacks/test_attacks_slsqp.py | 2 +- .../v1/attacks/test_attacks_sparsefool.py | 2 +- .../tests/v1/attacks/test_attacks_spatial.py | 2 +- 28 files changed, 49 insertions(+), 49 deletions(-) diff --git a/foolbox/tests/test_adversarial.py b/foolbox/tests/test_adversarial.py index 66ec7dbd..0ac123b1 100644 --- a/foolbox/tests/test_adversarial.py +++ b/foolbox/tests/test_adversarial.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox import Adversarial +from foolbox.v1 import Adversarial from foolbox.distances import MSE import foolbox @@ -147,8 +147,8 @@ def test_adversarial(model, criterion, image, label): def test_inplace(bn_model, bn_adversarial, bn_label): - class TestAttack(foolbox.attacks.Attack): - @foolbox.attacks.base.call_decorator + class TestAttack(foolbox.v1.attacks.Attack): + @foolbox.v1.attacks.base.call_decorator def __call__(self, input_or_adv, label, unpack): a = input_or_adv x = np.zeros_like(a.unperturbed) diff --git a/foolbox/tests/v1/attacks/test_attacks_adef_attack.py b/foolbox/tests/v1/attacks/test_attacks_adef_attack.py index cfe66df5..91087396 100644 --- a/foolbox/tests/v1/attacks/test_attacks_adef_attack.py +++ b/foolbox/tests/v1/attacks/test_attacks_adef_attack.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.attacks import ADefAttack as Attack +from foolbox.v1.attacks import ADefAttack as Attack def test_attack_pytorch(bn_adversarial_pytorch): diff --git a/foolbox/tests/v1/attacks/test_attacks_approx_lbfgs.py b/foolbox/tests/v1/attacks/test_attacks_approx_lbfgs.py index bde3ff57..f96cd191 100644 --- a/foolbox/tests/v1/attacks/test_attacks_approx_lbfgs.py +++ b/foolbox/tests/v1/attacks/test_attacks_approx_lbfgs.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.attacks import ApproximateLBFGSAttack as Attack +from foolbox.v1.attacks import ApproximateLBFGSAttack as Attack def test_name(): diff --git a/foolbox/tests/v1/attacks/test_attacks_binarization.py b/foolbox/tests/v1/attacks/test_attacks_binarization.py index 1f4f0005..dde5c6be 100644 --- a/foolbox/tests/v1/attacks/test_attacks_binarization.py +++ b/foolbox/tests/v1/attacks/test_attacks_binarization.py @@ -1,8 +1,8 @@ import pytest import numpy as np -from foolbox.attacks import GradientAttack -from foolbox.attacks import BinarizationRefinementAttack +from foolbox.v1.attacks import GradientAttack +from foolbox.v1.attacks import BinarizationRefinementAttack def test_attack(binarized_bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_blur.py b/foolbox/tests/v1/attacks/test_attacks_blur.py index fd8f39aa..093cc551 100644 --- a/foolbox/tests/v1/attacks/test_attacks_blur.py +++ b/foolbox/tests/v1/attacks/test_attacks_blur.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.attacks import GaussianBlurAttack as Attack +from foolbox.v1.attacks import GaussianBlurAttack as Attack def test_attack(bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_boundary.py b/foolbox/tests/v1/attacks/test_attacks_boundary.py index bca3ace2..bef7aadb 100644 --- a/foolbox/tests/v1/attacks/test_attacks_boundary.py +++ b/foolbox/tests/v1/attacks/test_attacks_boundary.py @@ -1,9 +1,9 @@ import numpy as np import pytest -from foolbox.attacks import BoundaryAttack -from foolbox.attacks import DeepFoolAttack -from foolbox.attacks import BlendedUniformNoiseAttack +from foolbox.v1.attacks import BoundaryAttack +from foolbox.v1.attacks import DeepFoolAttack +from foolbox.v1.attacks import BlendedUniformNoiseAttack def test_attack(bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_carlini_wagner.py b/foolbox/tests/v1/attacks/test_attacks_carlini_wagner.py index 480ed251..2ebc5f87 100644 --- a/foolbox/tests/v1/attacks/test_attacks_carlini_wagner.py +++ b/foolbox/tests/v1/attacks/test_attacks_carlini_wagner.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.attacks import CarliniWagnerL2Attack as Attack +from foolbox.v1.attacks import CarliniWagnerL2Attack as Attack def test_untargeted_attack(bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_contrast.py b/foolbox/tests/v1/attacks/test_attacks_contrast.py index da3b89ce..798f4a20 100644 --- a/foolbox/tests/v1/attacks/test_attacks_contrast.py +++ b/foolbox/tests/v1/attacks/test_attacks_contrast.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.attacks import ContrastReductionAttack as Attack +from foolbox.v1.attacks import ContrastReductionAttack as Attack def test_attack(bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_decoupled_direction_norm.py b/foolbox/tests/v1/attacks/test_attacks_decoupled_direction_norm.py index 1c2374bd..1acbf018 100644 --- a/foolbox/tests/v1/attacks/test_attacks_decoupled_direction_norm.py +++ b/foolbox/tests/v1/attacks/test_attacks_decoupled_direction_norm.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.attacks import DecoupledDirectionNormL2Attack as Attack +from foolbox.v1.attacks import DecoupledDirectionNormL2Attack as Attack def test_untargeted_attack(bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_deepfool.py b/foolbox/tests/v1/attacks/test_attacks_deepfool.py index 2b47378b..4616b61a 100644 --- a/foolbox/tests/v1/attacks/test_attacks_deepfool.py +++ b/foolbox/tests/v1/attacks/test_attacks_deepfool.py @@ -1,9 +1,9 @@ import pytest import numpy as np -from foolbox.attacks import DeepFoolAttack -from foolbox.attacks import DeepFoolL2Attack -from foolbox.attacks import DeepFoolLinfinityAttack +from foolbox.v1.attacks import DeepFoolAttack +from foolbox.v1.attacks import DeepFoolL2Attack +from foolbox.v1.attacks import DeepFoolLinfinityAttack Attacks = [DeepFoolAttack, DeepFoolL2Attack, DeepFoolLinfinityAttack] diff --git a/foolbox/tests/v1/attacks/test_attacks_ead.py b/foolbox/tests/v1/attacks/test_attacks_ead.py index f4e4fdd2..8d722ed1 100644 --- a/foolbox/tests/v1/attacks/test_attacks_ead.py +++ b/foolbox/tests/v1/attacks/test_attacks_ead.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.attacks import EADAttack as Attack +from foolbox.v1.attacks import EADAttack as Attack def test_untargeted_attack(bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_gradient.py b/foolbox/tests/v1/attacks/test_attacks_gradient.py index a5da8853..c17ce361 100644 --- a/foolbox/tests/v1/attacks/test_attacks_gradient.py +++ b/foolbox/tests/v1/attacks/test_attacks_gradient.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.attacks import GradientAttack as Attack +from foolbox.v1.attacks import GradientAttack as Attack def test_attack(bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_gradient_sign.py b/foolbox/tests/v1/attacks/test_attacks_gradient_sign.py index 4f69c5a3..bbbae889 100644 --- a/foolbox/tests/v1/attacks/test_attacks_gradient_sign.py +++ b/foolbox/tests/v1/attacks/test_attacks_gradient_sign.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.attacks import GradientSignAttack as Attack +from foolbox.v1.attacks import GradientSignAttack as Attack def test_attack(bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_hsja.py b/foolbox/tests/v1/attacks/test_attacks_hsja.py index d75b5a82..28b58618 100644 --- a/foolbox/tests/v1/attacks/test_attacks_hsja.py +++ b/foolbox/tests/v1/attacks/test_attacks_hsja.py @@ -1,7 +1,7 @@ import numpy as np -from foolbox.attacks import HopSkipJumpAttack, BoundaryAttackPlusPlus -from foolbox.attacks import BlendedUniformNoiseAttack +from foolbox.v1.attacks import HopSkipJumpAttack, BoundaryAttackPlusPlus +from foolbox.v1.attacks import BlendedUniformNoiseAttack from foolbox.distances import Linf diff --git a/foolbox/tests/v1/attacks/test_attacks_iterative_gradient.py b/foolbox/tests/v1/attacks/test_attacks_iterative_gradient.py index 6104baaf..244c89da 100644 --- a/foolbox/tests/v1/attacks/test_attacks_iterative_gradient.py +++ b/foolbox/tests/v1/attacks/test_attacks_iterative_gradient.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.attacks import IterativeGradientAttack as Attack +from foolbox.v1.attacks import IterativeGradientAttack as Attack def test_attack(bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_iterative_gradient_sign.py b/foolbox/tests/v1/attacks/test_attacks_iterative_gradient_sign.py index 4b2b05bf..b920a9e8 100644 --- a/foolbox/tests/v1/attacks/test_attacks_iterative_gradient_sign.py +++ b/foolbox/tests/v1/attacks/test_attacks_iterative_gradient_sign.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.attacks import IterativeGradientSignAttack as Attack +from foolbox.v1.attacks import IterativeGradientSignAttack as Attack def test_attack(bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_iterative_projected_gradient.py b/foolbox/tests/v1/attacks/test_attacks_iterative_projected_gradient.py index 37e6f8e5..5c760cd1 100644 --- a/foolbox/tests/v1/attacks/test_attacks_iterative_projected_gradient.py +++ b/foolbox/tests/v1/attacks/test_attacks_iterative_projected_gradient.py @@ -1,17 +1,17 @@ import pytest import numpy as np -from foolbox.attacks import LinfinityBasicIterativeAttack -from foolbox.attacks import L1BasicIterativeAttack -from foolbox.attacks import L2BasicIterativeAttack -from foolbox.attacks import ProjectedGradientDescentAttack -from foolbox.attacks import RandomStartProjectedGradientDescentAttack -from foolbox.attacks import MomentumIterativeAttack - -from foolbox.attacks import AdamL1BasicIterativeAttack -from foolbox.attacks import AdamL2BasicIterativeAttack -from foolbox.attacks import AdamProjectedGradientDescentAttack -from foolbox.attacks import AdamRandomStartProjectedGradientDescentAttack +from foolbox.v1.attacks import LinfinityBasicIterativeAttack +from foolbox.v1.attacks import L1BasicIterativeAttack +from foolbox.v1.attacks import L2BasicIterativeAttack +from foolbox.v1.attacks import ProjectedGradientDescentAttack +from foolbox.v1.attacks import RandomStartProjectedGradientDescentAttack +from foolbox.v1.attacks import MomentumIterativeAttack + +from foolbox.v1.attacks import AdamL1BasicIterativeAttack +from foolbox.v1.attacks import AdamL2BasicIterativeAttack +from foolbox.v1.attacks import AdamProjectedGradientDescentAttack +from foolbox.v1.attacks import AdamRandomStartProjectedGradientDescentAttack Attacks = [ LinfinityBasicIterativeAttack, diff --git a/foolbox/tests/v1/attacks/test_attacks_lbfgs.py b/foolbox/tests/v1/attacks/test_attacks_lbfgs.py index b7a8783d..d0a956b5 100644 --- a/foolbox/tests/v1/attacks/test_attacks_lbfgs.py +++ b/foolbox/tests/v1/attacks/test_attacks_lbfgs.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.attacks import LBFGSAttack as Attack +from foolbox.v1.attacks import LBFGSAttack as Attack def test_attack(bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_localsearch.py b/foolbox/tests/v1/attacks/test_attacks_localsearch.py index 236a61c8..effd58f8 100644 --- a/foolbox/tests/v1/attacks/test_attacks_localsearch.py +++ b/foolbox/tests/v1/attacks/test_attacks_localsearch.py @@ -1,7 +1,7 @@ import numpy as np from foolbox import set_seeds -from foolbox.attacks import LocalSearchAttack as Attack +from foolbox.v1.attacks import LocalSearchAttack as Attack def test_attack(bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_newtonfool.py b/foolbox/tests/v1/attacks/test_attacks_newtonfool.py index f6c9ba77..3a8f80ef 100644 --- a/foolbox/tests/v1/attacks/test_attacks_newtonfool.py +++ b/foolbox/tests/v1/attacks/test_attacks_newtonfool.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.attacks import NewtonFoolAttack as Attack +from foolbox.v1.attacks import NewtonFoolAttack as Attack def test_attack(bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_noise.py b/foolbox/tests/v1/attacks/test_attacks_noise.py index f4fb015f..80134b2a 100644 --- a/foolbox/tests/v1/attacks/test_attacks_noise.py +++ b/foolbox/tests/v1/attacks/test_attacks_noise.py @@ -1,10 +1,10 @@ import pytest import numpy as np -from foolbox.attacks import AdditiveUniformNoiseAttack -from foolbox.attacks import AdditiveGaussianNoiseAttack -from foolbox.attacks import SaltAndPepperNoiseAttack -from foolbox.attacks import BlendedUniformNoiseAttack +from foolbox.v1.attacks import AdditiveUniformNoiseAttack +from foolbox.v1.attacks import AdditiveGaussianNoiseAttack +from foolbox.v1.attacks import SaltAndPepperNoiseAttack +from foolbox.v1.attacks import BlendedUniformNoiseAttack Attacks = [ AdditiveUniformNoiseAttack, diff --git a/foolbox/tests/v1/attacks/test_attacks_pointwise.py b/foolbox/tests/v1/attacks/test_attacks_pointwise.py index 8d5e1a15..97748d8a 100644 --- a/foolbox/tests/v1/attacks/test_attacks_pointwise.py +++ b/foolbox/tests/v1/attacks/test_attacks_pointwise.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.attacks import PointwiseAttack as Attack +from foolbox.v1.attacks import PointwiseAttack as Attack def test_attack(bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_precomputed.py b/foolbox/tests/v1/attacks/test_attacks_precomputed.py index 17d0db0f..b81de8eb 100644 --- a/foolbox/tests/v1/attacks/test_attacks_precomputed.py +++ b/foolbox/tests/v1/attacks/test_attacks_precomputed.py @@ -1,7 +1,7 @@ import numpy as np import pytest -from foolbox.attacks import PrecomputedAdversarialsAttack as Attack +from foolbox.v1.attacks import PrecomputedAdversarialsAttack as Attack def test_attack(bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_saliency.py b/foolbox/tests/v1/attacks/test_attacks_saliency.py index ec478153..2bc8b15c 100644 --- a/foolbox/tests/v1/attacks/test_attacks_saliency.py +++ b/foolbox/tests/v1/attacks/test_attacks_saliency.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.attacks import SaliencyMapAttack as Attack +from foolbox.v1.attacks import SaliencyMapAttack as Attack def test_attack(bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_singlepixel.py b/foolbox/tests/v1/attacks/test_attacks_singlepixel.py index be6ae074..6b34b2ad 100644 --- a/foolbox/tests/v1/attacks/test_attacks_singlepixel.py +++ b/foolbox/tests/v1/attacks/test_attacks_singlepixel.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.attacks import SinglePixelAttack as Attack +from foolbox.v1.attacks import SinglePixelAttack as Attack def test_attack(bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_slsqp.py b/foolbox/tests/v1/attacks/test_attacks_slsqp.py index b2313c7d..46bd4941 100644 --- a/foolbox/tests/v1/attacks/test_attacks_slsqp.py +++ b/foolbox/tests/v1/attacks/test_attacks_slsqp.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.attacks import SLSQPAttack as Attack +from foolbox.v1.attacks import SLSQPAttack as Attack def test_attack(bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_sparsefool.py b/foolbox/tests/v1/attacks/test_attacks_sparsefool.py index 3c029d28..51d74851 100644 --- a/foolbox/tests/v1/attacks/test_attacks_sparsefool.py +++ b/foolbox/tests/v1/attacks/test_attacks_sparsefool.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.attacks import SparseFoolAttack as Attack +from foolbox.v1.attacks import SparseFoolAttack as Attack def test_attack(bn_adversarial): diff --git a/foolbox/tests/v1/attacks/test_attacks_spatial.py b/foolbox/tests/v1/attacks/test_attacks_spatial.py index 6db40d24..9ef4dd7e 100644 --- a/foolbox/tests/v1/attacks/test_attacks_spatial.py +++ b/foolbox/tests/v1/attacks/test_attacks_spatial.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.attacks import SpatialAttack as Attack +from foolbox.v1.attacks import SpatialAttack as Attack def test_attack_pytorch(bn_adversarial_pytorch): From 4394422b02777e0d23a4e4a72ddb33d3430cddf6 Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 10:20:43 +0200 Subject: [PATCH 19/25] updated imports in tests --- .../attacks/test_batch_attacks_adef_attack.py | 2 +- .../test_batch_attacks_binarization.py | 4 ++-- .../tests/attacks/test_batch_attacks_blur.py | 2 +- .../attacks/test_batch_attacks_boundary.py | 2 +- .../attacks/test_batch_attacks_contrast.py | 2 +- ..._batch_attacks_decoupled_direction_norm.py | 2 +- .../attacks/test_batch_attacks_deepfool.py | 6 ++--- .../tests/attacks/test_batch_attacks_hsja.py | 4 ++-- .../attacks/test_batch_attacks_inversion.py | 2 +- .../test_batch_attacks_iterative_gradient.py | 2 +- ...t_batch_attacks_iterative_gradient_sign.py | 2 +- .../attacks/test_batch_attacks_localsearch.py | 2 +- .../attacks/test_batch_attacks_newtonfool.py | 2 +- .../tests/attacks/test_batch_attacks_noise.py | 8 +++---- .../attacks/test_batch_attacks_pointwise.py | 2 +- .../attacks/test_batch_attacks_precomputed.py | 2 +- .../attacks/test_batch_attacks_saliency.py | 2 +- .../attacks/test_batch_attacks_singlepixel.py | 2 +- .../attacks/test_batch_attacks_spatial.py | 2 +- .../attacks/test_batch_carlini_wagner.py | 2 +- foolbox/tests/attacks/test_batch_ead.py | 2 +- foolbox/tests/attacks/test_batch_gen.py | 2 +- foolbox/tests/attacks/test_batch_gradient.py | 2 +- .../tests/attacks/test_batch_gradient_sign.py | 2 +- ...test_batch_iterative_projected_gradient.py | 24 +++++++++---------- .../attacks/test_batch_virtual_adversarial.py | 2 +- foolbox/v1/attacks/base.py | 3 +-- 27 files changed, 45 insertions(+), 46 deletions(-) diff --git a/foolbox/tests/attacks/test_batch_attacks_adef_attack.py b/foolbox/tests/attacks/test_batch_attacks_adef_attack.py index 72479034..0728bcdf 100644 --- a/foolbox/tests/attacks/test_batch_attacks_adef_attack.py +++ b/foolbox/tests/attacks/test_batch_attacks_adef_attack.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.batch_attacks import ADefAttack as Attack +from foolbox.attacks import ADefAttack as Attack def test_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_attacks_binarization.py b/foolbox/tests/attacks/test_batch_attacks_binarization.py index f43beca1..80bcefa4 100644 --- a/foolbox/tests/attacks/test_batch_attacks_binarization.py +++ b/foolbox/tests/attacks/test_batch_attacks_binarization.py @@ -1,8 +1,8 @@ import pytest import numpy as np -from foolbox.batch_attacks import GradientAttack -from foolbox.batch_attacks import BinarizationRefinementAttack +from foolbox.attacks import GradientAttack +from foolbox.attacks import BinarizationRefinementAttack def test_attack(binarized_bn_model, bn_criterion, bn_images, binarized_bn_labels): diff --git a/foolbox/tests/attacks/test_batch_attacks_blur.py b/foolbox/tests/attacks/test_batch_attacks_blur.py index d1252b17..2d524846 100644 --- a/foolbox/tests/attacks/test_batch_attacks_blur.py +++ b/foolbox/tests/attacks/test_batch_attacks_blur.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.batch_attacks import GaussianBlurAttack as Attack +from foolbox.attacks import GaussianBlurAttack as Attack def test_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_attacks_boundary.py b/foolbox/tests/attacks/test_batch_attacks_boundary.py index a1339a13..27d00f52 100644 --- a/foolbox/tests/attacks/test_batch_attacks_boundary.py +++ b/foolbox/tests/attacks/test_batch_attacks_boundary.py @@ -1,7 +1,7 @@ import numpy as np import pytest -from foolbox.batch_attacks import BoundaryAttack +from foolbox.attacks import BoundaryAttack def test_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_attacks_contrast.py b/foolbox/tests/attacks/test_batch_attacks_contrast.py index 5f925362..84f5d8b5 100644 --- a/foolbox/tests/attacks/test_batch_attacks_contrast.py +++ b/foolbox/tests/attacks/test_batch_attacks_contrast.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.batch_attacks import ContrastReductionAttack as Attack +from foolbox.attacks import ContrastReductionAttack as Attack def test_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_attacks_decoupled_direction_norm.py b/foolbox/tests/attacks/test_batch_attacks_decoupled_direction_norm.py index ac75dd12..19264113 100644 --- a/foolbox/tests/attacks/test_batch_attacks_decoupled_direction_norm.py +++ b/foolbox/tests/attacks/test_batch_attacks_decoupled_direction_norm.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.batch_attacks import DecoupledDirectionNormL2Attack as Attack +from foolbox.attacks import DecoupledDirectionNormL2Attack as Attack def test_untargeted_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_attacks_deepfool.py b/foolbox/tests/attacks/test_batch_attacks_deepfool.py index 0abcdfe3..604da4b3 100644 --- a/foolbox/tests/attacks/test_batch_attacks_deepfool.py +++ b/foolbox/tests/attacks/test_batch_attacks_deepfool.py @@ -1,9 +1,9 @@ import pytest import numpy as np -from foolbox.batch_attacks import DeepFoolAttack -from foolbox.batch_attacks import DeepFoolL2Attack -from foolbox.batch_attacks import DeepFoolLinfinityAttack +from foolbox.attacks import DeepFoolAttack +from foolbox.attacks import DeepFoolL2Attack +from foolbox.attacks import DeepFoolLinfinityAttack from foolbox.distances import MAE from foolbox.distances import Linf diff --git a/foolbox/tests/attacks/test_batch_attacks_hsja.py b/foolbox/tests/attacks/test_batch_attacks_hsja.py index bdcc0772..cd8ee919 100644 --- a/foolbox/tests/attacks/test_batch_attacks_hsja.py +++ b/foolbox/tests/attacks/test_batch_attacks_hsja.py @@ -1,7 +1,7 @@ import numpy as np -from foolbox.batch_attacks import HopSkipJumpAttack, BoundaryAttackPlusPlus -from foolbox.batch_attacks import BlendedUniformNoiseAttack +from foolbox.attacks import HopSkipJumpAttack, BoundaryAttackPlusPlus +from foolbox.attacks import BlendedUniformNoiseAttack from foolbox.distances import Linf diff --git a/foolbox/tests/attacks/test_batch_attacks_inversion.py b/foolbox/tests/attacks/test_batch_attacks_inversion.py index f6b02c61..f3988d22 100644 --- a/foolbox/tests/attacks/test_batch_attacks_inversion.py +++ b/foolbox/tests/attacks/test_batch_attacks_inversion.py @@ -1,7 +1,7 @@ import numpy as np import pytest -from foolbox.batch_attacks import InversionAttack as Attack +from foolbox.attacks import InversionAttack as Attack def test_untargeted_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_attacks_iterative_gradient.py b/foolbox/tests/attacks/test_batch_attacks_iterative_gradient.py index 8fb16ac4..746f7f5b 100644 --- a/foolbox/tests/attacks/test_batch_attacks_iterative_gradient.py +++ b/foolbox/tests/attacks/test_batch_attacks_iterative_gradient.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.batch_attacks import IterativeGradientAttack as Attack +from foolbox.attacks import IterativeGradientAttack as Attack def test_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_attacks_iterative_gradient_sign.py b/foolbox/tests/attacks/test_batch_attacks_iterative_gradient_sign.py index 9cfe006f..92de839e 100644 --- a/foolbox/tests/attacks/test_batch_attacks_iterative_gradient_sign.py +++ b/foolbox/tests/attacks/test_batch_attacks_iterative_gradient_sign.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.batch_attacks import IterativeGradientSignAttack as Attack +from foolbox.attacks import IterativeGradientSignAttack as Attack def test_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_attacks_localsearch.py b/foolbox/tests/attacks/test_batch_attacks_localsearch.py index 3b54b60c..16cce213 100644 --- a/foolbox/tests/attacks/test_batch_attacks_localsearch.py +++ b/foolbox/tests/attacks/test_batch_attacks_localsearch.py @@ -1,7 +1,7 @@ import numpy as np from foolbox import set_seeds -from foolbox.batch_attacks import LocalSearchAttack as Attack +from foolbox.attacks import LocalSearchAttack as Attack def test_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_attacks_newtonfool.py b/foolbox/tests/attacks/test_batch_attacks_newtonfool.py index 6b7722ac..81b9b7fb 100644 --- a/foolbox/tests/attacks/test_batch_attacks_newtonfool.py +++ b/foolbox/tests/attacks/test_batch_attacks_newtonfool.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.batch_attacks import NewtonFoolAttack as Attack +from foolbox.attacks import NewtonFoolAttack as Attack def test_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_attacks_noise.py b/foolbox/tests/attacks/test_batch_attacks_noise.py index 89654bde..98a50ec7 100644 --- a/foolbox/tests/attacks/test_batch_attacks_noise.py +++ b/foolbox/tests/attacks/test_batch_attacks_noise.py @@ -1,10 +1,10 @@ import pytest import numpy as np -from foolbox.batch_attacks import AdditiveUniformNoiseAttack -from foolbox.batch_attacks import AdditiveGaussianNoiseAttack -from foolbox.batch_attacks import SaltAndPepperNoiseAttack -from foolbox.batch_attacks import BlendedUniformNoiseAttack +from foolbox.attacks import AdditiveUniformNoiseAttack +from foolbox.attacks import AdditiveGaussianNoiseAttack +from foolbox.attacks import SaltAndPepperNoiseAttack +from foolbox.attacks import BlendedUniformNoiseAttack Attacks = [ AdditiveUniformNoiseAttack, diff --git a/foolbox/tests/attacks/test_batch_attacks_pointwise.py b/foolbox/tests/attacks/test_batch_attacks_pointwise.py index 6e2f6977..1cb06192 100644 --- a/foolbox/tests/attacks/test_batch_attacks_pointwise.py +++ b/foolbox/tests/attacks/test_batch_attacks_pointwise.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.batch_attacks import PointwiseAttack as Attack +from foolbox.attacks import PointwiseAttack as Attack def test_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_attacks_precomputed.py b/foolbox/tests/attacks/test_batch_attacks_precomputed.py index 87ed6f83..bccd64b5 100644 --- a/foolbox/tests/attacks/test_batch_attacks_precomputed.py +++ b/foolbox/tests/attacks/test_batch_attacks_precomputed.py @@ -1,7 +1,7 @@ import numpy as np import pytest -from foolbox.batch_attacks import PrecomputedAdversarialsAttack as Attack +from foolbox.attacks import PrecomputedAdversarialsAttack as Attack def test_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_attacks_saliency.py b/foolbox/tests/attacks/test_batch_attacks_saliency.py index 1847acbf..ad6a0a07 100644 --- a/foolbox/tests/attacks/test_batch_attacks_saliency.py +++ b/foolbox/tests/attacks/test_batch_attacks_saliency.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.batch_attacks import SaliencyMapAttack as Attack +from foolbox.attacks import SaliencyMapAttack as Attack def test_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_attacks_singlepixel.py b/foolbox/tests/attacks/test_batch_attacks_singlepixel.py index ab2530a8..df982b20 100644 --- a/foolbox/tests/attacks/test_batch_attacks_singlepixel.py +++ b/foolbox/tests/attacks/test_batch_attacks_singlepixel.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.batch_attacks import SinglePixelAttack as Attack +from foolbox.attacks import SinglePixelAttack as Attack def test_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_attacks_spatial.py b/foolbox/tests/attacks/test_batch_attacks_spatial.py index f4009304..9c72d5da 100644 --- a/foolbox/tests/attacks/test_batch_attacks_spatial.py +++ b/foolbox/tests/attacks/test_batch_attacks_spatial.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.batch_attacks import SpatialAttack as Attack +from foolbox.attacks import SpatialAttack as Attack def test_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_carlini_wagner.py b/foolbox/tests/attacks/test_batch_carlini_wagner.py index 152e019c..64b3c486 100644 --- a/foolbox/tests/attacks/test_batch_carlini_wagner.py +++ b/foolbox/tests/attacks/test_batch_carlini_wagner.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.batch_attacks import CarliniWagnerL2Attack as Attack +from foolbox.attacks import CarliniWagnerL2Attack as Attack def test_untargeted_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_ead.py b/foolbox/tests/attacks/test_batch_ead.py index 89c62bb2..b6b604be 100644 --- a/foolbox/tests/attacks/test_batch_ead.py +++ b/foolbox/tests/attacks/test_batch_ead.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.batch_attacks import EADAttack as Attack +from foolbox.attacks import EADAttack as Attack def test_untargeted_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_gen.py b/foolbox/tests/attacks/test_batch_gen.py index 7f393c23..5018c974 100644 --- a/foolbox/tests/attacks/test_batch_gen.py +++ b/foolbox/tests/attacks/test_batch_gen.py @@ -1,7 +1,7 @@ import pytest import numpy as np -from foolbox.batch_attacks import GenAttack as Attack +from foolbox.attacks import GenAttack as Attack def test_untargeted_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_gradient.py b/foolbox/tests/attacks/test_batch_gradient.py index 895f73d1..1e571b3c 100644 --- a/foolbox/tests/attacks/test_batch_gradient.py +++ b/foolbox/tests/attacks/test_batch_gradient.py @@ -6,7 +6,7 @@ from foolbox.models import ModelWithEstimatedGradients -from foolbox.batch_attacks import GradientAttack as Attack +from foolbox.attacks import GradientAttack as Attack def test_untargeted_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_gradient_sign.py b/foolbox/tests/attacks/test_batch_gradient_sign.py index 8f752d0e..c2b43388 100644 --- a/foolbox/tests/attacks/test_batch_gradient_sign.py +++ b/foolbox/tests/attacks/test_batch_gradient_sign.py @@ -1,6 +1,6 @@ import numpy as np -from foolbox.batch_attacks import GradientSignAttack as Attack +from foolbox.attacks import GradientSignAttack as Attack def test_untargeted_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/tests/attacks/test_batch_iterative_projected_gradient.py b/foolbox/tests/attacks/test_batch_iterative_projected_gradient.py index f7a24f2e..086377a0 100644 --- a/foolbox/tests/attacks/test_batch_iterative_projected_gradient.py +++ b/foolbox/tests/attacks/test_batch_iterative_projected_gradient.py @@ -1,18 +1,18 @@ import pytest import numpy as np -from foolbox.batch_attacks import LinfinityBasicIterativeAttack -from foolbox.batch_attacks import L1BasicIterativeAttack -from foolbox.batch_attacks import L2BasicIterativeAttack -from foolbox.batch_attacks import ProjectedGradientDescentAttack -from foolbox.batch_attacks import RandomStartProjectedGradientDescentAttack -from foolbox.batch_attacks import MomentumIterativeAttack -from foolbox.batch_attacks import SparseL1BasicIterativeAttack - -from foolbox.batch_attacks import AdamL1BasicIterativeAttack -from foolbox.batch_attacks import AdamL2BasicIterativeAttack -from foolbox.batch_attacks import AdamProjectedGradientDescentAttack -from foolbox.batch_attacks import AdamRandomStartProjectedGradientDescentAttack +from foolbox.attacks import LinfinityBasicIterativeAttack +from foolbox.attacks import L1BasicIterativeAttack +from foolbox.attacks import L2BasicIterativeAttack +from foolbox.attacks import ProjectedGradientDescentAttack +from foolbox.attacks import RandomStartProjectedGradientDescentAttack +from foolbox.attacks import MomentumIterativeAttack +from foolbox.attacks import SparseL1BasicIterativeAttack + +from foolbox.attacks import AdamL1BasicIterativeAttack +from foolbox.attacks import AdamL2BasicIterativeAttack +from foolbox.attacks import AdamProjectedGradientDescentAttack +from foolbox.attacks import AdamRandomStartProjectedGradientDescentAttack from foolbox.distances import Linfinity from foolbox.distances import MAE diff --git a/foolbox/tests/attacks/test_batch_virtual_adversarial.py b/foolbox/tests/attacks/test_batch_virtual_adversarial.py index b3391cc1..dffdc7fa 100644 --- a/foolbox/tests/attacks/test_batch_virtual_adversarial.py +++ b/foolbox/tests/attacks/test_batch_virtual_adversarial.py @@ -1,6 +1,6 @@ import numpy as np import pytest -from foolbox.batch_attacks import VirtualAdversarialAttack as Attack +from foolbox.attacks import VirtualAdversarialAttack as Attack def test_untargeted_attack(bn_model, bn_criterion, bn_images, bn_labels): diff --git a/foolbox/v1/attacks/base.py b/foolbox/v1/attacks/base.py index 555b8a4a..5870ad06 100644 --- a/foolbox/v1/attacks/base.py +++ b/foolbox/v1/attacks/base.py @@ -98,8 +98,7 @@ def wrapper(self, input_or_adv, label=None, unpack=True, **kwargs): if isinstance(input_or_adv, YieldingAdversarial): raise ValueError( - "If you pass an Adversarial instance, it must not be a YieldingAdversarial instance" - " when calling non-batch-supporting attacks like this one (check foolbox.batch_attacks)." + "foolbox.v1.attacks do not support batches and require a foolbox.v1.Adversarial instance" ) elif isinstance(input_or_adv, Adversarial): a = input_or_adv From 01c8a39b8496c7f56d80261b9fb6d69f9f29a756 Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 10:21:51 +0200 Subject: [PATCH 20/25] fixed import --- foolbox/tests/test_batching.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foolbox/tests/test_batching.py b/foolbox/tests/test_batching.py index a6c892a1..35b4d403 100644 --- a/foolbox/tests/test_batching.py +++ b/foolbox/tests/test_batching.py @@ -1,7 +1,7 @@ import numpy as np import pytest -from foolbox.batch_attacks import GradientAttack as Attack +from foolbox.attacks import GradientAttack as Attack from foolbox import run_parallel from foolbox import run_sequential From e4d822116f12d9ec10e4568654d3512ddfa173db Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 10:28:44 +0200 Subject: [PATCH 21/25] updated docs to show v1 attacks separately from attacks --- docs/index.rst | 1 + docs/modules/v1_attacks.rst | 97 ++++++++++++++++ docs/modules/v1_attacks/decision.rst | 50 ++++++++ docs/modules/v1_attacks/gradient.rst | 164 +++++++++++++++++++++++++++ docs/modules/v1_attacks/other.rst | 16 +++ docs/modules/v1_attacks/score.rst | 16 +++ 6 files changed, 344 insertions(+) create mode 100644 docs/modules/v1_attacks.rst create mode 100644 docs/modules/v1_attacks/decision.rst create mode 100644 docs/modules/v1_attacks/gradient.rst create mode 100644 docs/modules/v1_attacks/other.rst create mode 100644 docs/modules/v1_attacks/score.rst diff --git a/docs/index.rst b/docs/index.rst index e0ae20a4..afa07134 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -41,6 +41,7 @@ The source code and a `minimal working example`_ can be found on `GitHub`_. modules/attacks modules/adversarial modules/utils + modules/v1_attacks Indices and tables ================== diff --git a/docs/modules/v1_attacks.rst b/docs/modules/v1_attacks.rst new file mode 100644 index 00000000..6e3414a9 --- /dev/null +++ b/docs/modules/v1_attacks.rst @@ -0,0 +1,97 @@ +:mod:`foolbox.v1.attacks` +================================ + +.. automodule:: foolbox.v1.attacks + +.. toctree:: + :hidden: + + v1_attacks/gradient + v1_attacks/score + v1_attacks/decision + v1_attacks/other + + +.. rubric:: :doc:`v1_attacks/gradient` + +.. autosummary:: + :nosignatures: + + GradientAttack + GradientSignAttack + FGSM + LinfinityBasicIterativeAttack + BasicIterativeMethod + BIM + L1BasicIterativeAttack + L2BasicIterativeAttack + ProjectedGradientDescentAttack + ProjectedGradientDescent + PGD + RandomStartProjectedGradientDescentAttack + RandomProjectedGradientDescent + RandomPGD + AdamL1BasicIterativeAttack + AdamL2BasicIterativeAttack + AdamProjectedGradientDescentAttack + AdamProjectedGradientDescent + AdamPGD + AdamRandomStartProjectedGradientDescentAttack + AdamRandomProjectedGradientDescent + AdamRandomPGD + MomentumIterativeAttack + MomentumIterativeMethod + LBFGSAttack + DeepFoolAttack + NewtonFoolAttack + DeepFoolL2Attack + DeepFoolLinfinityAttack + ADefAttack + SLSQPAttack + SaliencyMapAttack + IterativeGradientAttack + IterativeGradientSignAttack + CarliniWagnerL2Attack + EADAttack + DecoupledDirectionNormL2Attack + SparseFoolAttack + SparseL1BasicIterativeAttack + VirtualAdversarialAttack + +.. rubric:: :doc:`v1_attacks/score` + +.. autosummary:: + :nosignatures: + + SinglePixelAttack + LocalSearchAttack + ApproximateLBFGSAttack + + +.. rubric:: :doc:`v1_attacks/decision` + +.. autosummary:: + :nosignatures: + + BoundaryAttack + SpatialAttack + PointwiseAttack + GaussianBlurAttack + ContrastReductionAttack + AdditiveUniformNoiseAttack + AdditiveGaussianNoiseAttack + SaltAndPepperNoiseAttack + BlendedUniformNoiseAttack + BoundaryAttackPlusPlus + GenAttack + HopSkipJumpAttack + + +.. rubric:: :doc:`v1_attacks/other` + +.. autosummary:: + :nosignatures: + + BinarizationRefinementAttack + PrecomputedAdversarialsAttack + InversionAttack diff --git a/docs/modules/v1_attacks/decision.rst b/docs/modules/v1_attacks/decision.rst new file mode 100644 index 00000000..08cde1f8 --- /dev/null +++ b/docs/modules/v1_attacks/decision.rst @@ -0,0 +1,50 @@ +Decision-based attacks +----------------- + +.. currentmodule:: foolbox.attacks + +.. autoclass:: BoundaryAttack + :members: + :special-members: + +.. autoclass:: SpatialAttack + :members: + :special-members: + +.. autoclass:: PointwiseAttack + :members: + :special-members: + +.. autoclass:: GaussianBlurAttack + :members: + :special-members: + +.. autoclass:: ContrastReductionAttack + :members: + :special-members: + +.. autoclass:: AdditiveUniformNoiseAttack + :members: + :special-members: + :inherited-members: + +.. autoclass:: AdditiveGaussianNoiseAttack + :members: + :special-members: + :inherited-members: + +.. autoclass:: SaltAndPepperNoiseAttack + :members: + :special-members: + +.. autoclass:: BlendedUniformNoiseAttack + :members: + :special-members: + +.. autoclass:: HopSkipJumpAttack + :members: + :special-members: + +.. autoclass:: GenAttack + :members: + :special-members: diff --git a/docs/modules/v1_attacks/gradient.rst b/docs/modules/v1_attacks/gradient.rst new file mode 100644 index 00000000..58f2d4ed --- /dev/null +++ b/docs/modules/v1_attacks/gradient.rst @@ -0,0 +1,164 @@ +Gradient-based attacks +---------------------- + +.. currentmodule:: foolbox.attacks + +.. autoclass:: GradientAttack + :members: + :special-members: + +.. autoclass:: GradientSignAttack + :members: + :special-members: + +.. autoclass:: FGSM + :members: + :special-members: + +.. autoclass:: LinfinityBasicIterativeAttack + :members: + :special-members: + +.. autoclass:: BasicIterativeMethod + :members: + :special-members: + +.. autoclass:: BIM + :members: + :special-members: + +.. autoclass:: L1BasicIterativeAttack + :members: + :special-members: + +.. autoclass:: L2BasicIterativeAttack + :members: + :special-members: + +.. autoclass:: ProjectedGradientDescentAttack + :members: + :special-members: + +.. autoclass:: ProjectedGradientDescent + :members: + :special-members: + +.. autoclass:: PGD + :members: + :special-members: + +.. autoclass:: RandomStartProjectedGradientDescentAttack + :members: + :special-members: + +.. autoclass:: RandomProjectedGradientDescent + :members: + :special-members: + +.. autoclass:: RandomPGD + :members: + :special-members: + +.. autoclass:: AdamL1BasicIterativeAttack + :members: + :special-members: + +.. autoclass:: AdamL2BasicIterativeAttack + :members: + :special-members: + +.. autoclass:: AdamProjectedGradientDescentAttack + :members: + :special-members: + +.. autoclass:: AdamProjectedGradientDescent + :members: + :special-members: + +.. autoclass:: AdamPGD + :members: + :special-members: + +.. autoclass:: AdamRandomStartProjectedGradientDescentAttack + :members: + :special-members: + +.. autoclass:: AdamRandomProjectedGradientDescent + :members: + :special-members: + +.. autoclass:: AdamRandomPGD + :members: + :special-members: + +.. autoclass:: MomentumIterativeAttack + :members: + :special-members: + +.. autoclass:: MomentumIterativeMethod + :members: + :special-members: + +.. autoclass:: LBFGSAttack + :members: + :special-members: + +.. autoclass:: DeepFoolAttack + :members: + :special-members: + +.. autoclass:: NewtonFoolAttack + :members: + :special-members: + +.. autoclass:: DeepFoolL2Attack + :members: + :special-members: + +.. autoclass:: DeepFoolLinfinityAttack + :members: + :special-members: + +.. autoclass:: ADefAttack + :members: + :special-members: + +.. autoclass:: SLSQPAttack + :members: + :special-members: + +.. autoclass:: SaliencyMapAttack + :members: + :special-members: + +.. autoclass:: IterativeGradientAttack + :members: + :special-members: + +.. autoclass:: IterativeGradientSignAttack + :members: + :special-members: + +.. autoclass:: CarliniWagnerL2Attack + :members: + :special-members: + +.. autoclass:: EADAttack + :members: + :special-members: + +.. autoclass:: DecoupledDirectionNormL2Attack + :members: + :special-members: + +.. autoclass:: SparseFoolAttack + :members: + :special-members: + +.. autoclass:: SparseL1BasicIterativeAttack + :members: + :special-members: + +.. autoclass:: VirtualAdversarialAttack + :members: + :special-members: diff --git a/docs/modules/v1_attacks/other.rst b/docs/modules/v1_attacks/other.rst new file mode 100644 index 00000000..d039a666 --- /dev/null +++ b/docs/modules/v1_attacks/other.rst @@ -0,0 +1,16 @@ +Other attacks +------------- + +.. currentmodule:: foolbox.attacks + +.. autoclass:: BinarizationRefinementAttack + :members: + :special-members: + +.. autoclass:: PrecomputedAdversarialsAttack + :members: + :special-members: + +.. autoclass:: InversionAttack + :members: + :special-members: diff --git a/docs/modules/v1_attacks/score.rst b/docs/modules/v1_attacks/score.rst new file mode 100644 index 00000000..70e094cc --- /dev/null +++ b/docs/modules/v1_attacks/score.rst @@ -0,0 +1,16 @@ +Score-based attacks +----------------- + +.. currentmodule:: foolbox.attacks + +.. autoclass:: SinglePixelAttack + :members: + :special-members: + +.. autoclass:: LocalSearchAttack + :members: + :special-members: + +.. autoclass:: ApproximateLBFGSAttack + :members: + :special-members: From 1254ff23918099bc99fce7be720eb161a7a9136f Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 10:29:57 +0200 Subject: [PATCH 22/25] added v1.Adversarial to docs --- docs/index.rst | 1 + docs/modules/v1_adversarial.rst | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 docs/modules/v1_adversarial.rst diff --git a/docs/index.rst b/docs/index.rst index afa07134..32ac8b58 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -42,6 +42,7 @@ The source code and a `minimal working example`_ can be found on `GitHub`_. modules/adversarial modules/utils modules/v1_attacks + modules/v1_adversarial Indices and tables ================== diff --git a/docs/modules/v1_adversarial.rst b/docs/modules/v1_adversarial.rst new file mode 100644 index 00000000..b6117207 --- /dev/null +++ b/docs/modules/v1_adversarial.rst @@ -0,0 +1,7 @@ +:mod:`foolbox.v1.adversarial` +==================================== + +.. automodule:: foolbox.v1.adversarial + +.. autoclass:: Adversarial + :members: From 9cbc60c4a01e82b719908f623f85329c82f66e31 Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 10:33:29 +0200 Subject: [PATCH 23/25] fixed init_attack check in pointwise attack --- foolbox/attacks/pointwise.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/foolbox/attacks/pointwise.py b/foolbox/attacks/pointwise.py index 47ed3271..654550fb 100644 --- a/foolbox/attacks/pointwise.py +++ b/foolbox/attacks/pointwise.py @@ -1,7 +1,6 @@ import warnings import logging -from .base import Attack from .base import Attack from .base import generator_decorator from .saltandpepper import SaltAndPepperNoiseAttack @@ -199,7 +198,7 @@ def initialize_starting_point(self, a): " Falling back to {} for initialization.".format(init_attack.__name__) ) - if issubclass(init_attack, Attack) or issubclass(init_attack, Attack): + if issubclass(init_attack, Attack): # instantiate if necessary init_attack = init_attack() From f0a582594565ee844ed8a8f1aae34dbdf10b675d Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 10:37:25 +0200 Subject: [PATCH 24/25] fixed imports --- foolbox/v1/attacks/additive_noise.py | 2 +- foolbox/v1/attacks/blended_noise.py | 2 +- foolbox/v1/attacks/iterative_projected_gradient.py | 2 +- foolbox/v1/attacks/lbfgs.py | 2 +- foolbox/v1/attacks/localsearch.py | 2 +- foolbox/v1/attacks/pointwise.py | 2 +- foolbox/v1/attacks/saliency.py | 2 +- foolbox/v1/attacks/saltandpepper.py | 2 +- foolbox/v1/attacks/slsqp.py | 2 +- foolbox/v1/attacks/spatial.py | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/foolbox/v1/attacks/additive_noise.py b/foolbox/v1/attacks/additive_noise.py index e0e1f16a..cdc264e4 100644 --- a/foolbox/v1/attacks/additive_noise.py +++ b/foolbox/v1/attacks/additive_noise.py @@ -5,7 +5,7 @@ from .base import Attack from .base import call_decorator -from .. import nprng +from ... import nprng class AdditiveNoiseAttack(Attack): diff --git a/foolbox/v1/attacks/blended_noise.py b/foolbox/v1/attacks/blended_noise.py index ea749cd4..c98a3ab8 100644 --- a/foolbox/v1/attacks/blended_noise.py +++ b/foolbox/v1/attacks/blended_noise.py @@ -6,7 +6,7 @@ from .base import Attack from .base import call_decorator -from .. import nprng +from ... import nprng class BlendedUniformNoiseAttack(Attack): diff --git a/foolbox/v1/attacks/iterative_projected_gradient.py b/foolbox/v1/attacks/iterative_projected_gradient.py index ff6c870a..0847fd00 100644 --- a/foolbox/v1/attacks/iterative_projected_gradient.py +++ b/foolbox/v1/attacks/iterative_projected_gradient.py @@ -7,7 +7,7 @@ from .base import call_decorator from .. import distances from ..utils import crossentropy -from .. import nprng +from ... import nprng from ..optimizers import AdamOptimizer from ..optimizers import GDOptimizer diff --git a/foolbox/v1/attacks/lbfgs.py b/foolbox/v1/attacks/lbfgs.py index c34ed64c..39318b80 100644 --- a/foolbox/v1/attacks/lbfgs.py +++ b/foolbox/v1/attacks/lbfgs.py @@ -7,7 +7,7 @@ from .base import call_decorator from .gradient import GradientAttack from ..utils import crossentropy as utils_ce -from .. import rng +from ... import rng class LBFGSAttack(Attack): diff --git a/foolbox/v1/attacks/localsearch.py b/foolbox/v1/attacks/localsearch.py index 18f48292..ea5d3172 100644 --- a/foolbox/v1/attacks/localsearch.py +++ b/foolbox/v1/attacks/localsearch.py @@ -3,7 +3,7 @@ from .base import Attack from .base import call_decorator from ..utils import softmax -from .. import nprng +from ... import nprng class SinglePixelAttack(Attack): diff --git a/foolbox/v1/attacks/pointwise.py b/foolbox/v1/attacks/pointwise.py index bce3a782..df1a4193 100644 --- a/foolbox/v1/attacks/pointwise.py +++ b/foolbox/v1/attacks/pointwise.py @@ -4,7 +4,7 @@ from .base import Attack from .base import call_decorator from .saltandpepper import SaltAndPepperNoiseAttack -from .. import rng +from ... import rng class PointwiseAttack(Attack): diff --git a/foolbox/v1/attacks/saliency.py b/foolbox/v1/attacks/saliency.py index f820066b..cbc055b9 100644 --- a/foolbox/v1/attacks/saliency.py +++ b/foolbox/v1/attacks/saliency.py @@ -5,7 +5,7 @@ from .base import Attack from .base import call_decorator from .gradient import GradientAttack -from .. import rng +from ... import rng class SaliencyMapAttack(Attack): diff --git a/foolbox/v1/attacks/saltandpepper.py b/foolbox/v1/attacks/saltandpepper.py index b390091a..20d76647 100644 --- a/foolbox/v1/attacks/saltandpepper.py +++ b/foolbox/v1/attacks/saltandpepper.py @@ -2,7 +2,7 @@ from .base import Attack from .base import call_decorator -from .. import nprng +from ... import nprng class SaltAndPepperNoiseAttack(Attack): diff --git a/foolbox/v1/attacks/slsqp.py b/foolbox/v1/attacks/slsqp.py index 09b7b9bb..0a772988 100644 --- a/foolbox/v1/attacks/slsqp.py +++ b/foolbox/v1/attacks/slsqp.py @@ -2,7 +2,7 @@ from .base import Attack from .base import call_decorator -from .. import nprng +from ... import nprng class SLSQPAttack(Attack): diff --git a/foolbox/v1/attacks/spatial.py b/foolbox/v1/attacks/spatial.py index f096acfc..39a090d3 100644 --- a/foolbox/v1/attacks/spatial.py +++ b/foolbox/v1/attacks/spatial.py @@ -5,7 +5,7 @@ from .base import Attack from .base import call_decorator -from .. import nprng +from ... import nprng class SpatialAttack(Attack): From 7806c6fe18dd326142621eee17376a4fa04fb79e Mon Sep 17 00:00:00 2001 From: Jonas Rauber Date: Wed, 23 Oct 2019 14:25:16 +0200 Subject: [PATCH 25/25] fixed imports --- foolbox/attacks/base.py | 2 +- foolbox/tests/test_attacks.py | 4 ++-- foolbox/v1/adversarial.py | 4 ++-- foolbox/v1/attacks/base.py | 6 +++--- foolbox/v1/attacks/carlini_wagner.py | 2 +- foolbox/v1/attacks/deepfool.py | 6 +++--- foolbox/v1/attacks/ead.py | 2 +- foolbox/v1/attacks/hop_skip_jump_attack.py | 4 ++-- foolbox/v1/attacks/iterative_projected_gradient.py | 8 ++++---- foolbox/v1/attacks/lbfgs.py | 2 +- foolbox/v1/attacks/localsearch.py | 2 +- foolbox/v1/attacks/newtonfool.py | 2 +- foolbox/v1/attacks/sparsefool.py | 2 +- 13 files changed, 23 insertions(+), 23 deletions(-) diff --git a/foolbox/attacks/base.py b/foolbox/attacks/base.py index 750987ec..b556d4e6 100644 --- a/foolbox/attacks/base.py +++ b/foolbox/attacks/base.py @@ -4,7 +4,7 @@ import numpy as np from ..v1.attacks.base import Attack as BaseAttack -from ..advesarial import Adversarial +from ..adversarial import Adversarial from ..adversarial import StopAttack from ..batching import run_parallel diff --git a/foolbox/tests/test_attacks.py b/foolbox/tests/test_attacks.py index 947f9d27..c44bded7 100644 --- a/foolbox/tests/test_attacks.py +++ b/foolbox/tests/test_attacks.py @@ -1,8 +1,8 @@ from unittest.mock import Mock import pytest -from foolbox import attacks -from foolbox import Adversarial +from foolbox.v1 import attacks +from foolbox.v1 import Adversarial # def test_abstract_attack(): diff --git a/foolbox/v1/adversarial.py b/foolbox/v1/adversarial.py index 399a19e4..e23794e3 100644 --- a/foolbox/v1/adversarial.py +++ b/foolbox/v1/adversarial.py @@ -6,8 +6,8 @@ import numpy as np import numbers -from .distances import Distance -from .distances import MSE +from ..distances import Distance +from ..distances import MSE class StopAttack(Exception): diff --git a/foolbox/v1/attacks/base.py b/foolbox/v1/attacks/base.py index 5870ad06..e4b5410e 100644 --- a/foolbox/v1/attacks/base.py +++ b/foolbox/v1/attacks/base.py @@ -5,10 +5,10 @@ from abc import abstractmethod from ..adversarial import Adversarial -from ...adversarial import Adversarial as YieldingAdversarial from ..adversarial import StopAttack -from ..criteria import Misclassification -from ..distances import MSE +from ...adversarial import Adversarial as YieldingAdversarial +from ...criteria import Misclassification +from ...distances import MSE class Attack(abc.ABC): diff --git a/foolbox/v1/attacks/carlini_wagner.py b/foolbox/v1/attacks/carlini_wagner.py index eb754b7b..ae915321 100644 --- a/foolbox/v1/attacks/carlini_wagner.py +++ b/foolbox/v1/attacks/carlini_wagner.py @@ -3,7 +3,7 @@ from .base import Attack from .base import call_decorator -from ..utils import onehot_like +from ...utils import onehot_like class CarliniWagnerL2Attack(Attack): diff --git a/foolbox/v1/attacks/deepfool.py b/foolbox/v1/attacks/deepfool.py index 60385be6..bd8cbc19 100644 --- a/foolbox/v1/attacks/deepfool.py +++ b/foolbox/v1/attacks/deepfool.py @@ -4,9 +4,9 @@ from .base import Attack from .base import call_decorator -from ..utils import crossentropy -from ..distances import MeanSquaredDistance -from ..distances import Linfinity +from ...utils import crossentropy +from ...distances import MeanSquaredDistance +from ...distances import Linfinity class DeepFoolAttack(Attack): diff --git a/foolbox/v1/attacks/ead.py b/foolbox/v1/attacks/ead.py index 7775b103..b346c852 100644 --- a/foolbox/v1/attacks/ead.py +++ b/foolbox/v1/attacks/ead.py @@ -3,7 +3,7 @@ from .base import Attack from .base import call_decorator -from ..utils import onehot_like +from ...utils import onehot_like class EADAttack(Attack): diff --git a/foolbox/v1/attacks/hop_skip_jump_attack.py b/foolbox/v1/attacks/hop_skip_jump_attack.py index ed22490d..263d03a8 100644 --- a/foolbox/v1/attacks/hop_skip_jump_attack.py +++ b/foolbox/v1/attacks/hop_skip_jump_attack.py @@ -4,8 +4,8 @@ from .base import Attack from .base import call_decorator -from ..distances import MSE, Linf -from ..criteria import Misclassification +from ...distances import MSE, Linf +from ...criteria import Misclassification import numpy as np import math from warnings import warn diff --git a/foolbox/v1/attacks/iterative_projected_gradient.py b/foolbox/v1/attacks/iterative_projected_gradient.py index 0847fd00..d68ce0c5 100644 --- a/foolbox/v1/attacks/iterative_projected_gradient.py +++ b/foolbox/v1/attacks/iterative_projected_gradient.py @@ -5,11 +5,11 @@ from .base import Attack from .base import call_decorator -from .. import distances -from ..utils import crossentropy +from ... import distances +from ...utils import crossentropy from ... import nprng -from ..optimizers import AdamOptimizer -from ..optimizers import GDOptimizer +from ...optimizers import AdamOptimizer +from ...optimizers import GDOptimizer class IterativeProjectedGradientBaseAttack(Attack): diff --git a/foolbox/v1/attacks/lbfgs.py b/foolbox/v1/attacks/lbfgs.py index 39318b80..fcc74a3a 100644 --- a/foolbox/v1/attacks/lbfgs.py +++ b/foolbox/v1/attacks/lbfgs.py @@ -6,7 +6,7 @@ from .base import Attack from .base import call_decorator from .gradient import GradientAttack -from ..utils import crossentropy as utils_ce +from ...utils import crossentropy as utils_ce from ... import rng diff --git a/foolbox/v1/attacks/localsearch.py b/foolbox/v1/attacks/localsearch.py index ea5d3172..1da523c3 100644 --- a/foolbox/v1/attacks/localsearch.py +++ b/foolbox/v1/attacks/localsearch.py @@ -2,7 +2,7 @@ from .base import Attack from .base import call_decorator -from ..utils import softmax +from ...utils import softmax from ... import nprng diff --git a/foolbox/v1/attacks/newtonfool.py b/foolbox/v1/attacks/newtonfool.py index 0bdc9dcf..b81f57c2 100644 --- a/foolbox/v1/attacks/newtonfool.py +++ b/foolbox/v1/attacks/newtonfool.py @@ -2,7 +2,7 @@ from .base import Attack from .base import call_decorator -from ..utils import softmax +from ...utils import softmax import numpy as np diff --git a/foolbox/v1/attacks/sparsefool.py b/foolbox/v1/attacks/sparsefool.py index 94b36642..e0a3ccfc 100644 --- a/foolbox/v1/attacks/sparsefool.py +++ b/foolbox/v1/attacks/sparsefool.py @@ -4,7 +4,7 @@ from .base import Attack from .base import call_decorator -from ..utils import crossentropy +from ...utils import crossentropy class SparseFoolAttack(Attack):