DSE-MSU / DeepRobust

A pytorch adversarial library for attack and defense methods on images and graphs
MIT License
994 stars 192 forks source link

The problem of graph adversarial attacks #132

Open renhl717445 opened 1 year ago

renhl717445 commented 1 year ago

I would like to ask if the adversarial example attacks on the graph are all for GCN? Could it be applied to other inductive graph neural network models, such as GAT and GraphSAGE?

ChandlerBang commented 1 year ago

Hi,

Thanks for your interest in DeepRobust. I wanted to clarify a few points here:

  1. The most straightforward way to attack other models (GAT and GraphSAGE) is to use the attacked graph generated by GCN (which is the default backbone model). In detail, we first use attack methods to attack GCN model and obtain the attacked graph. Then we feed this attacked graph to other models. The attacked graph is shown to be able to transfer to attack other models.
  2. You can also use GraphSAGE/GAT as backbone models. But these models do not directly take the edge_weight as input, so we did modification on the model. An example is shown in test_prbcd_cora.py. Try:
    pip install deeprobust==0.2.8
    python examples/graph/test_prbcd_cora.py
renhl717445 commented 1 year ago

Thank you for your reply. I am running python examples/graph/test_gcn_jaccard.py --dataset cora, but an error occurs. Isn't the zip file loaded? I used python=3.8,pytorch=1.12.1,and deeprobust==0.2.7. There is no deeprobust==0.2.8.

/opt/conda/envs/graph/bin/python3.8 /root/.pycharm_helpers/pydev/pydevd.py --multiprocess --qt-support=auto --client localhost --port 37615 --file /home/Huali Ren/DeepRobust-master/examples/graph/test_gcn_jaccard.py Connected to pydev debugger (build 223.8617.48) cuda: True Loading cora dataset... python-BaseException Traceback (most recent call last): File "/opt/conda/envs/graph/lib/python3.8/site-packages/numpy/lib/npyio.py", line 420, in load ret = NpzFile(fid, own_fid=own_fid, allow_pickle=allow_pickle, File "/opt/conda/envs/graph/lib/python3.8/site-packages/numpy/lib/npyio.py", line 187, in init _zip = zipfile_factory(fid) File "/opt/conda/envs/graph/lib/python3.8/site-packages/numpy/lib/npyio.py", line 103, in zipfile_factory return zipfile.ZipFile(file, *args, **kwargs) File "/opt/conda/envs/graph/lib/python3.8/zipfile.py", line 1269, in init self._RealGetContents() File "/opt/conda/envs/graph/lib/python3.8/zipfile.py", line 1336, in _RealGetContents raise BadZipFile("File is not a zip file") zipfile.BadZipFile: File is not a zip file

Process finished with exit code 1

ChandlerBang commented 1 year ago

Hi, can you try it again? It works well on my side "pip install deeprobust==0.2.8"

renhl717445 commented 1 year ago

Yes, it still can't be installed on my side. In addition, I would like to ask whether IG's countersample generation code is provided by the source author? Because I found that the attack success rate obtained by running test_ig.py on citeseer dataset is less than 40%, but nettack's method can reach more than 90%. May I ask what parameters need to be adjusted?