Skip to content

Commit 94ebb4e

Browse files
committed
refactor: misc
1 parent 7670e3a commit 94ebb4e

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ loguru
1515
IPython
1616
pytest
1717
prettytable
18+
imagesize
1819

1920
# api
2021
tencentcloud-sdk-python

scripts/attack_blackbox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def parse_args():
143143
_('--no-smart-median', action='store_true', help='disable gradient-efficient median approximation')
144144
_('--precise-noise', action='store_true', help='use the straightforward scaling-aware noise sampling')
145145
# Misc
146-
_('-o', '--output', type=Path, default='static/blackbox-results', help='path to output directory')
146+
_('-o', '--output', type=Path, default='static/logs', help='path to output directory')
147147
_('-t', '--tag', default='', type=str, help='name for this experiment')
148148
_('-g', '--gpu', default=0, type=int, help='GPU id')
149149
args = parser.parse_args()

src/attacks/sign_opt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ def generate(self, x0: np.ndarray, y0: int, tag=None):
151151

152152
# logging
153153
nb_query += grad_queries + ls_count
154-
pbar.set_postfix({'query': nb_query, 'l2': f'{gg:.3f}'})
155-
self.log.append((i, nb_query, gg))
154+
pbar.set_postfix({'query': nb_query, 'l2': f'{gg:.5f}'})
155+
self.log.append((nb_query, gg))
156156

157157
# stop if we reach the query limit
158158
if nb_query > self.max_query:

src/defenses/prevention.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ def __init__(self, *args, **kwargs):
134134
def pooling(self, x: torch.Tensor) -> torch.Tensor:
135135
x = self.unfold(x)
136136

137-
low = x.quantile(0.3, dim=-1)[..., None]
137+
low = x.quantile(0.2, dim=-1)[..., None]
138138
med = x.median(dim=-1).values[..., None]
139-
high = x.quantile(0.7, dim=-1)[..., None]
139+
high = x.quantile(0.8, dim=-1)[..., None]
140140
ind = (low <= x) * (x <= high) * (1 - (x - med).abs())
141141

142142
out = (x * ind).sum(dim=-1) / ind.sum(dim=-1)

0 commit comments

Comments
 (0)