Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repreduce the results of PRECODE #3

Open
chenxiang3luo opened this issue Oct 18, 2024 · 0 comments
Open

Repreduce the results of PRECODE #3

chenxiang3luo opened this issue Oct 18, 2024 · 0 comments

Comments

@chenxiang3luo
Copy link

Thank you for your outstanding work. I want to recover the data under PRECODE defense with ROG. But when I change the LeNet to LeNetVB like the model in PRECODE, the code always reports bugs that RuntimeError: size mismatch, got input (16), mat (16x256), vec (512)

Traceback (most recent call last):
  File "/data2/chenxiang/svd_defense/rog/attack_fedavg.py", line 7, in <module>
    main("config_fedavg.yaml",int(sys.argv[1]))
  File "/data2/chenxiang/svd_defense/rog/main.py", line 87, in main
    recon_data = grad_inv(attacker, grad, x, onehot, model, config, logger)
  File "/data2/chenxiang/svd_defense/rog/src/attack/attacker.py", line 269, in grad_inv
    dummy_data = attacker.multistep_attack(grad, x, onehot, model, config.tau, logger)
  File "/data2/chenxiang/svd_defense/rog/src/attack/attacker.py", line 235, in multistep_attack
    dummy_data_optimizer.step(closure)
  File "/home/chenxiang/anaconda3/envs/svd/lib/python3.10/site-packages/torch/optim/lr_scheduler.py", line 75, in wrapper
    return wrapped(*args, **kwargs)
  File "/home/chenxiang/anaconda3/envs/svd/lib/python3.10/site-packages/torch/optim/optimizer.py", line 385, in wrapper
    out = func(*args, **kwargs)
  File "/home/chenxiang/anaconda3/envs/svd/lib/python3.10/site-packages/torch/optim/optimizer.py", line 76, in _use_grad
    ret = func(self, *args, **kwargs)
  File "/home/chenxiang/anaconda3/envs/svd/lib/python3.10/site-packages/torch/optim/adam.py", line 146, in step
    loss = closure()
  File "/data2/chenxiang/svd_defense/rog/src/attack/attacker.py", line 209, in closure
    pred = meta_net(F.interpolate(dummy_data, scale_factor=self.sf, mode='bicubic'))
  File "/home/chenxiang/anaconda3/envs/svd/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/chenxiang/anaconda3/envs/svd/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
  File "/data2/chenxiang/svd_defense/rog/networks/metanet.py", line 83, in forward
    output = self.net(inputs)
  File "/home/chenxiang/anaconda3/envs/svd/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/chenxiang/anaconda3/envs/svd/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
  File "/data2/chenxiang/svd_defense/rog/networks/vgg.py", line 189, in forward
    x = self.VB(x)
  File "/home/chenxiang/anaconda3/envs/svd/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/chenxiang/anaconda3/envs/svd/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
  File "/data2/chenxiang/svd_defense/rog/networks/precodenet/VariationalBlock.py", line 59, in forward
    x = self.decoder(encoding.unsqueeze(0))
  File "/home/chenxiang/anaconda3/envs/svd/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "/home/chenxiang/anaconda3/envs/svd/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
RuntimeError: size mismatch, got input (16), mat (16x256), vec (512)

I have checked the tensor size and layer size. By the way, the vgg7_vb in your code is vgg7, so there is no example I could learn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant