From f18c07734c3de48ec31802bc5e9738a4ea09332b Mon Sep 17 00:00:00 2001 From: Andrew Ilyas Date: Fri, 10 Jul 2020 00:31:32 -0400 Subject: [PATCH 1/3] fix type checking for dataset init and increment version --- robustness/__init__.py | 2 +- robustness/attack_steps.py | 1 - robustness/datasets.py | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/robustness/__init__.py b/robustness/__init__.py index 78f22b6..1e9c668 100644 --- a/robustness/__init__.py +++ b/robustness/__init__.py @@ -1,2 +1,2 @@ name = "robustness" -__version__ = "1.0.post1" +__version__ = "1.2.post1" diff --git a/robustness/attack_steps.py b/robustness/attack_steps.py index 61bd38a..f74b03d 100644 --- a/robustness/attack_steps.py +++ b/robustness/attack_steps.py @@ -122,7 +122,6 @@ def project(self, x): def step(self, x, g): """ """ - # Scale g so that each element of the batch is at least norm 1 l = len(x.shape) - 1 g_norm = ch.norm(g.view(g.shape[0], -1), dim=1).view(-1, *([1]*l)) scaled_g = g / (g_norm + 1e-10) diff --git a/robustness/datasets.py b/robustness/datasets.py index bab1b88..732dd19 100644 --- a/robustness/datasets.py +++ b/robustness/datasets.py @@ -88,7 +88,7 @@ def override_args(self, default_args, new_args): if len(extra_args) > 0: raise ValueError(f"Invalid arguments: {extra_args}") for k in kwargs: req_type = type(default_args[k]) - if not isinstance(kwargs[k], req_type): + if (default_args[k] is not None) and (not isinstance(kwargs[k], req_type)): raise ValueError(f"Argument {k} should have type {req_type}") return {**default_args, **kwargs} From 504bacff49763ec8dec45cfcbb130dea7419710c Mon Sep 17 00:00:00 2001 From: Andrew Ilyas Date: Fri, 10 Jul 2020 00:34:13 -0400 Subject: [PATCH 2/3] increment version in setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 677f14c..04de9d0 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # https://packaging.python.org/en/latest/single_source_version.html - version='1.2', + version='1.2.post1', description='Tools for Robustness', long_description=long_description, From 148be0062f503ea0e31ce3907ccb1f27305e1d65 Mon Sep 17 00:00:00 2001 From: Andrew Ilyas Date: Sat, 11 Jul 2020 00:19:27 -0400 Subject: [PATCH 3/3] add none condition --- robustness/datasets.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/robustness/datasets.py b/robustness/datasets.py index 732dd19..e67bebe 100644 --- a/robustness/datasets.py +++ b/robustness/datasets.py @@ -88,7 +88,8 @@ def override_args(self, default_args, new_args): if len(extra_args) > 0: raise ValueError(f"Invalid arguments: {extra_args}") for k in kwargs: req_type = type(default_args[k]) - if (default_args[k] is not None) and (not isinstance(kwargs[k], req_type)): + no_nones = (default_args[k] is not None) and (kwargs[k] is not None) + if no_nones and (not isinstance(kwargs[k], req_type)): raise ValueError(f"Argument {k} should have type {req_type}") return {**default_args, **kwargs}