Skip to content

Commit

Permalink
amd: make ics aap only
Browse files Browse the repository at this point in the history
  • Loading branch information
cdluminate committed Nov 22, 2021
1 parent 4e488ba commit 6054252
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions robrank/defenses/amd.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,18 +622,11 @@ def hm_training_step(model: th.nn.Module, batch, batch_idx, *,
if gradual:
model._hm_prev_loss = loss.item()
if ics:
loss = loss + 0.5 * (
model.lossfunc.raw(
loss = loss + 1.0 * model.lossfunc.raw(
ap_orig[:len(ap_orig)//2],
pnemb[:len(pnemb) // 3],
ap_orig[len(ap_orig)//2:],
override_margin=0.0)
+ model.lossfunc.raw(
output_orig[pos, :],
pnemb[len(pnemb) // 3 : 2*len(pnemb)//3],
output_orig[anc, :],
override_margin=0.0)
)
# logging
model.log('Train/loss_orig', loss_orig.item())
model.log('Train/loss_adv', loss.item())
Expand Down

0 comments on commit 6054252

Please sign in to comment.