JonasGeiping / data-poisoning

Implementations of data poisoning attacks against neural networks and related defenses.
MIT License
66 stars 8 forks source link

Running with default parameters raises 'NoneType' error #2

Closed bjwh228 closed 3 months ago

bjwh228 commented 5 months ago

I am running the framework with the default parameters and after the clean training and one iteration of brewing poisons I am getting this error message:

Traceback (most recent call last): File "/home/b0whit15/data-poisoning/brew_poison.py", line 57, in poison_delta = witch.brew(model, data) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/b0whit15/data-poisoning/forest/witchcoven/witch_base.py", line 46, in brew poison_delta = self._brew(victim, kettle) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/b0whit15/data-poisoning/forest/witchcoven/witch_base.py", line 69, in _brew poison_delta, target_losses = self._run_trial(victim, kettle) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/b0whit15/data-poisoning/forest/witchcoven/witch_base.py", line 166, in _run_trial loss, prediction = self._batched_step(poison_delta, poison_bounds, example, victim, kettle) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/b0whit15/data-poisoning/forest/witchcoven/witch_base.py", line 301, in _batched_step poison_delta.grad[poison_slices] = delta_slice.grad.detach().to(device=torch.device('cpu'))


TypeError: 'NoneType' object does not support item assignment
hifi-hyp commented 3 months ago

same here.

JonasGeiping commented 3 months ago

You need this fix for modern pytorch versions: https://github.com/JonasGeiping/poisoning-gradient-matching/issues/4#issuecomment-1880547544

I'll update the repo to include it.