ALeLacheur commited on
Commit
f7c9d35
·
verified ·
1 Parent(s): 268fcc9

Update audio_diffusion_attacks_forhf/src/balancer.py

Browse files
audio_diffusion_attacks_forhf/src/balancer.py CHANGED
@@ -92,7 +92,8 @@ class Balancer:
92
  # Compute partial derivative of the less with respect to the input.
93
  #Andy added:
94
  loss.requires_grad = True
95
- grad, = autograd.grad(loss, [input], retain_graph=True)
 
96
  if self.per_batch_item:
97
  # We do not average the gradient over the batch dimension.
98
  dims = tuple(range(1, grad.dim()))
 
92
  # Compute partial derivative of the less with respect to the input.
93
  #Andy added:
94
  loss.requires_grad = True
95
+ #Andy edited--CHECK WITH WILLIAM: grad, = autograd.grad(loss, [input], retain_graph=True)
96
+ grad, = autograd.grad(loss, [input], retain_graph=True, allow_unused=True)
97
  if self.per_batch_item:
98
  # We do not average the gradient over the batch dimension.
99
  dims = tuple(range(1, grad.dim()))