liuyugeng / baadd

Code for Backdoor Attacks Against Dataset Distillation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When running python DD/main.py --mode distill_basic --dataset Cifar10 --arch AlexCifarNet --distill_lr 0.001 --naive --dataset_root /path/to/data --results_dir /path/to/results,there is a problem:AttributeError: 'NoneType' object has no attribute 'add_'

software-theorem opened this issue · comments

When running python DD/main.py --mode distill_basic --dataset Cifar10 --arch AlexCifarNet --distill_lr 0.001 --naive --dataset_root /path/to/data --results_dir /path/to/results,there is a problem:AttributeError: 'NoneType' object has no attribute 'add_'

Hi, please provide your working environment and the full error information. Many thanks!

my torch version:2.0.0.dev20230202+cu116
Linux 5.19.0-46-generic #47~22.04.1-Ubuntu
Traceback (most recent call last):
File "/home//data/distillationdefense/baadd-master/DD/main.py", line 422, in
main(options.get_state())
File "/home//data/distillationdefense/baadd-master/DD/main.py", line 142, in main
steps = train_distilled_image.distill(state, state.models)
File "/home//data/distillationdefense/baadd-master/DD/train_distilled_image.py", line 664, in distill
return Trainer(state, models).train()
File "/home//data/distillationdefense/baadd-master/DD/train_distilled_image.py", line 607, in train
self.accumulate_grad(grad_infos)
File "/home//data/distillationdefense/baadd-master/DD/train_distilled_image.py", line 504, in accumulate_grad
d.grad.add_(g)
AttributeError: 'NoneType' object has no attribute 'add_'

Hi, I think you need to downgrade the pytorch version to 1.x, since the DD code cannot be employed under pytorch 2.0.

Thank you for your reply!