Skip to content

Commit c83898f

Browse files
authored
Merge pull request #1212 from redwrasse/arctanh
use torch builtin arctanh method
2 parents 1115738 + 710e34b commit c83898f

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

cleverhans/torch/attacks/carlini_wagner_l2.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,10 @@ class (int).
114114
o_bestattack = x.clone().detach()
115115

116116
# Map images into the tanh-space
117-
# TODO as of 01/06/2020, PyTorch does not natively support
118-
# arctanh (see, e.g.,
119-
# https://github.com/pytorch/pytorch/issues/10324).
120-
# This particular implementation here is not numerically
121-
# stable and should be substituted w/ PyTorch's native
122-
# implementation when it comes out in the future
123-
arctanh = lambda x: 0.5 * torch.log((1 + x) / (1 - x))
124117
x = (x - clip_min) / (clip_max - clip_min)
125118
x = torch.clamp(x, 0, 1)
126119
x = x * 2 - 1
127-
x = arctanh(x * 0.999999)
120+
x = torch.arctanh(x * 0.999999)
128121

129122
# Prepare some variables
130123
modifier = torch.zeros_like(x, requires_grad=True)

0 commit comments

Comments
 (0)