File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -384,11 +384,11 @@ def select_poison_indices(
384384 model .eval ()
385385 differentiable_params = [p for p in classifier .model .parameters () if p .requires_grad ]
386386 for x , y in zip (x_samples , y_samples ):
387- image = torch .tensor (x ,dtype = torch .float32 ).float ().to (device )
387+ image = torch .tensor (x , dtype = torch .float32 ).float ().to (device )
388388 label = torch .tensor (y ).to (device )
389389 loss = criterion (model (image .unsqueeze (0 )), label .unsqueeze (0 ))
390390 gradients = torch .autograd .grad (loss , differentiable_params , only_inputs = True )
391- grad_norm = torch .tensor (0 ,dtype = torch .float32 ).to (device )
391+ grad_norm = torch .tensor (0 , dtype = torch .float32 ).to (device )
392392 for grad in gradients :
393393 grad_norm += grad .detach ().pow (2 ).sum ()
394394 grad_norms .append (grad_norm .sqrt ())
You can’t perform that action at this time.
0 commit comments