Skip to content

Commit

Permalink
Merge pull request #59 from MadryLab/custom_class_and_version
Browse files Browse the repository at this point in the history
fix type checking for dataset init and increment version
  • Loading branch information
andrewilyas committed Jul 11, 2020
2 parents e55de7c + 148be00 commit 375d9ef
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion robustness/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name = "robustness"
__version__ = "1.0.post1"
__version__ = "1.2.post1"
1 change: 0 additions & 1 deletion robustness/attack_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion robustness/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 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}

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 375d9ef

Please sign in to comment.