{"id":18454932,"url":"https://github.com/chandlerbang/pro-gnn","last_synced_at":"2025-04-09T12:05:28.408Z","repository":{"id":37288560,"uuid":"265676694","full_name":"ChandlerBang/Pro-GNN","owner":"ChandlerBang","description":"Implementation of the KDD 2020 paper \"Graph Structure Learning for Robust Graph Neural Networks\"","archived":false,"fork":false,"pushed_at":"2023-05-12T16:28:36.000Z","size":10334,"stargazers_count":293,"open_issues_count":10,"forks_count":45,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T09:09:09.656Z","etag":null,"topics":["adversarial-attacks","attack-defense","deep-learning","defense","graph-mining","graph-neural-networks","graph-structure-recovery","machine-learning","pytorch","semi-supervised-learning"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2005.10203","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChandlerBang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-20T20:15:06.000Z","updated_at":"2025-03-30T07:43:05.000Z","dependencies_parsed_at":"2024-12-17T15:10:52.930Z","dependency_job_id":"f46c69ef-af80-4110-89e3-4c8663d70d75","html_url":"https://github.com/ChandlerBang/Pro-GNN","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChandlerBang%2FPro-GNN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChandlerBang%2FPro-GNN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChandlerBang%2FPro-GNN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChandlerBang%2FPro-GNN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChandlerBang","download_url":"https://codeload.github.com/ChandlerBang/Pro-GNN/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248036063,"owners_count":21037092,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adversarial-attacks","attack-defense","deep-learning","defense","graph-mining","graph-neural-networks","graph-structure-recovery","machine-learning","pytorch","semi-supervised-learning"],"created_at":"2024-11-06T08:06:35.656Z","updated_at":"2025-04-09T12:05:28.379Z","avatar_url":"https://github.com/ChandlerBang.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pro-GNN \n\nA PyTorch implementation of \"Graph Structure Learning for Robust Graph Neural Networks\" (KDD 2020). [[paper]](https://arxiv.org/abs/2005.10203) [[slides]](http://cse.msu.edu/~jinwei2/files/Slides_ProGNN.pdf)\n\nThe code is based on our Pytorch adversarial repository, DeepRobust [(https://github.com/DSE-MSU/DeepRobust)](https://github.com/DSE-MSU/DeepRobust)\n\n\u003cdiv align=center\u003e\u003cimg src=\"https://raw.githubusercontent.com/ChandlerBang/Pro-GNN/master/ProGNN.png\" width=\"700\"/\u003e\u003c/div\u003e\n\nNote\n----\nAlthough in the original paper we did not provide the results on large-scale graphs, we encourage researchers to test your model on attacked large graphs. DeepRobust has provided APIs to perform scalable attacks and you can find an example in [test_prbcd.py](https://github.com/DSE-MSU/DeepRobust/blob/master/examples/graph/test_prbcd.py). \n\nAnother example is in our [ICLR'23 code](https://github.com/ChandlerBang/GTrans#robustness) where we tested our model robustness on the large attacked ogb-arxiv graph. \n\nPlease feel free to open an issue if you have any questions :)\n\n\n## Abstract \nGraph Neural Networks (GNNs) are powerful tools in representation learning for graphs. However, recent studies show that GNNs are vulnerable to carefully-crafted perturbations, called adversarial attacks. Adversarial attacks can easily fool GNNs in making predictions for downstream tasks. The vulnerability to adversarial attacks has raised increasing concerns for applying GNNs in safety-critical applications. Therefore, developing robust algorithms to defend adversarial attacks is of great significance. A natural idea to defend adversarial attacks is to clean the perturbed graph. It is evident that real-world graphs share some intrinsic properties. For example, many real-world graphs are low-rank and sparse, and the features of two adjacent nodes tend to be similar. In fact, we find that adversarial attacks are likely to violate these graph properties. Therefore, in this paper, we explore these properties to defend adversarial attacks on graphs. In particular, we propose a general framework Pro-GNN, which can jointly learn a structural graph and a robust graph neural network model from the perturbed graph guided by these properties. Extensive experiments on real-world graphs demonstrate that the proposed framework achieves significantly better performance compared with the state-of-the-art defense methods, even when the graph is heavily perturbed.\n\n## Requirements\nSee that in https://github.com/DSE-MSU/DeepRobust/blob/master/requirements.txt\n```\nmatplotlib==3.1.1\nnumpy==1.17.1\ntorch==1.2.0\nscipy==1.3.1\ntorchvision==0.4.0\ntexttable==1.6.2\nnetworkx==2.4\nnumba==0.48.0\nPillow==7.0.0\nscikit_learn==0.22.1\nskimage==0.0\ntensorboardX==2.0\n```\n\n## Installation\nTo run the code, first you need to install DeepRobust:\n```\npip install deeprobust\n```\nOr you can clone it and install from source code:\n```\ngit clone https://github.com/DSE-MSU/DeepRobust.git\ncd DeepRobust\npython setup.py install\n```\n\n## Run the code\nAfter installation, you can clone this repository\n```\ngit clone https://github.com/ChandlerBang/Pro-GNN.git\ncd Pro-GNN\npython train.py --dataset polblogs --attack meta --ptb_rate 0.15 --epoch 1000\n```\n\n## Reproduce the results\nAll the hyper-parameters settings are included in [`scripts`](https://github.com/ChandlerBang/Pro-GNN/tree/master/scripts) folder. Note that same hyper-parameters are used under different perturbation for the same dataset. \n\nTo reproduce the performance reported in the paper, you can run the bash files in folder `scripts`.\n```\nsh scripts/meta/cora_meta.sh\n```\nTo test performance under different severity of attack, you can change the `ptb_rate` in those bash files.\n\n\u003c!--\n**IMPORTANT NOTICE** For the performance of Pubmed dataset, if you don't add the code (line 59-62 in `train.py`), the performance of GCN should be around 85 since the data splits are different from what I used in the paper. See details in https://github.com/ChandlerBang/Pro-GNN/issues/2\n--\u003e\n\n## Generate attack by yourself\nWith the help of DeepRobust, you can run the following code to generate meta attack\n```\npython generate_attack.py --dataset cora --ptb_rate 0.05 --seed 15\n```\n\n## Cite\nFor more information, you can take a look at the [paper](https://arxiv.org/abs/2005.10203) or the detailed [code](https://github.com/DSE-MSU/DeepRobust/blob/master/deeprobust/graph/defense/prognn.py) shown in DeepRobust.\n\nIf you find this repo to be useful, please cite our paper. Thank you.\n```\n@inproceedings{jin2020graph,\n  title={Graph Structure Learning for Robust Graph Neural Networks},\n  author={Jin, Wei and Ma, Yao and Liu, Xiaorui and Tang, Xianfeng and Wang, Suhang and Tang, Jiliang},\n  booktitle={26th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, KDD 2020},\n  pages={66--74},\n  year={2020},\n  organization={Association for Computing Machinery}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchandlerbang%2Fpro-gnn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchandlerbang%2Fpro-gnn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchandlerbang%2Fpro-gnn/lists"}