wenzhu23333 / Differential-Privacy-Based-Federated-Learning

Everything you want about DP-Based Federated Learning, including Papers and Code. (Mechanism: Laplace or Gaussian, Dataset: femnist, shakespeare, mnist, cifar-10 and fashion-mnist. )
GNU General Public License v3.0
348 stars 55 forks source link

报错'Parameter' object has no attribute '_forward_counter' #4

Closed xiyuanyang45 closed 1 year ago

xiyuanyang45 commented 1 year ago

复现: git clone https://github.com/wenzhu23333/Differential-Privacy-Based-Federated-Learning.git cd Differential-Privacy-Based-Federated-Learning python3 -u main.py --dataset mnist --dp_mechanism Gaussian --dp_epsilon 30 --dp_clip 10 然后就报 Traceback (most recent call last): File "/home/yangxiyuan/prjs/DPBFL/main.py", line 144, in w, loss, curLR = local.train(net=copy.deepcopy(net_glob).to(args.device)) File "/home/yangxiyuan/prjs/DPBFL/models/Update.py", line 51, in train log_probs = net(images) File "/home/yangxiyuan/anaconda3/envs/unbreakable/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl return forward_call(*input, kwargs) File "/home/yangxiyuan/anaconda3/envs/unbreakable/lib/python3.10/site-packages/opacus/grad_sample/grad_sample_module.py", line 148, in forward return self._module(*args, *kwargs) File "/home/yangxiyuan/anaconda3/envs/unbreakable/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl return forward_call(input, kwargs) File "/home/yangxiyuan/prjs/DPBFL/models/Nets.py", line 38, in forward x = F.relu(F.max_pool2d(self.conv1(x), 2)) File "/home/yangxiyuan/anaconda3/envs/unbreakable/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1211, in _call_impl hook_result = hook(self, input, result) File "/home/yangxiyuan/anaconda3/envs/unbreakable/lib/python3.10/site-packages/opacus/grad_sample/grad_sample_module.py", line 288, in capture_activations_hook p._forward_counter += 1 AttributeError: 'Parameter' object has no attribute '_forward_counter'

torch:1.13.0 opacus:1.3.0

wenzhu23333 commented 1 year ago

尝试将opacus版本降级至0.15.0 pip install opacus==0.15.0