Code Monkey home page Code Monkey logo

ugba's Introduction

UGBA: Unnoticeable Backdoor Attack on Graph Neural Networks

An official PyTorch implementation of "Unnoticeable Backdoor Attack on Graph Neural Networks" (WWW 2023). [paper] If you find this repo to be useful, please cite our paper. Thank you.

@inproceedings{dai2023unnoticeable,
  title={Unnoticeable Backdoor Attacks on Graph Neural Networks},
  author={Dai, Enyan and Lin, Minhua and Zhang, Xiang and Wang, Suhang},
  booktitle={Proceedings of the ACM Web Conference 2023},
  pages={2263--2273},
  year={2023}
}

Content

1. Overview

  • ./models: This directory contains the model of UGBA.
  • ./data: The directory contains the original datasets used in the experiments
  • ./logs: The directory contains the log of the experimental results
  • ./script: It contains the scripts to reproduce the major reuslts of our paper.
  • ./selected_nodes: This directory contains the selected poisoned nodes for each dataset.
  • ./baseline_atk.py The framework of baseline node injection attack (i.e., TDGIA, AGIA).
  • ./run_adaptive.py: The program to run our UGBA attack.
  • ./run_clean.py: The program to run GNNs on clean graph under three defense settings to get clean accuracy.
  • ./run_GTA.py: The program to run baseline GTA attack from Xi, Zhaohan, et al. "Graph Backdoor".
  • ./run_NodeInjectionAtk.py: The program to run baseline node injection attack (i.e., TDGIA, AGIA).
  • ./run_SBA.py: The program to run baseline SBA-Samp and its variant SBA-Gen from Xi, Zhaohan, et al. "Backdoor Attacks to Graph Neural Networks".

2. Requirements

python==3.8.13
torch==1.12.1
torch-geometric==2.1.0
numpy==1.22.4
scipy==1.7.3
scikit-learn==1.1.1
scikit-learn-extra==0.2.0

The packages can be installed by directly run the commands in install.sh by

bash install.sh

3. UGBA

Abstract

Graph Neural Networks (GNNs) have achieved promising results in various tasks such as node classification and graph classification. Recent studies find that GNNs are vulnerable to adversarial attacks. However, effective backdoor attacks on graphs are still an open problem. In particular, backdoor attack poisons the graph by attaching triggers and the target class label to a set of nodes in the training graph. The backdoored GNNs trained on the poisoned graph will then be misled to predict test nodes to target class once attached with triggers. Though there are some initial efforts in graph backdoor attacks, our empirical analysis shows that they may require a large attack budget for effective backdoor attacks and the injected triggers can be easily detected and pruned. Therefore, in this paper, we study a novel problem of unnoticeable graph backdoor attacks with limited attack budget. To fully utilize the attack budget, we propose to deliberately select the nodes to inject triggers and target class labels in the poisoning phase. An adaptive trigger generator is deployed to obtain effective triggers that are difficult to be noticed. Extensive experiments on real-world datasets against various defense strategies demonstrate the effectiveness of our proposed method in conducting effective unnoticeable backdoor attacks.

Reproduce the Results

The hyper-parameters settings for the datasets are included in train_UGBA.sh To reproduce the performance reported in the paper, you can run the bash file:

bash script\train_UGBA.sh

To get the results of Baselines, you can run the bash file:

bash script\train_baseline.sh

To see the reproduce experimental results, please check the logs in ./logs

4. Compared Methods (to test)

Compared with Graph Backdoor Attack Methods

SBA-Samp

From Zhang, Zaixi, et al. "Backdoor Attacks to Graph Neural Networks" [paper, code].

SBA-Gen

This is a variant of SBA-Samp, which uses generated features for trigger nodes. Features are from a Gaussian distribution whose mean and variance is computed from real nodes.

GTA

From Xi, Zhaohan, et al. "Graph Backdoor" [paper, code].

Compared with Graph Injection Evasion Attack Methods

TDGIA

From Zou, Xu, et al. "TDGIA: Effective Injection Attacks on Graph Neural Networks." [paper, code].

AGIA

From Chen, Yongqiang, et al. "Understanding and Improving Graph Injection Attack by Promoting Unnoticeability" [paper, code].

Comparing with Defense Methods

Robust GCN

From Zhu, Dingyuan, et al. "Robust graph convolutional networks against adversarial attacks" [paper, code].

GNNGuard

From Zhang, Xiang, et al. "GNNGuard: Defending Graph Neural Networks against Adversarial Attacks" [paper, code].

5. Dataset

The experiments are conducted on four public real-world datasets, i.e., Cora, Pubmed, Flickr and OGB-Arxiv, which can be automatically downloaded to ./data through torch-geometric API.

ugba's People

Contributors

ventr1c avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ugba's Issues

The code seeems to lack discrete features and feature normalization?

Hi, I encountered confusion when testing datasets with discrete node features.

For example, the node features in the Cora dataset are discrete and are normalized with a L1 norm (i.e., data.x.sum(dim=1) is 1 and all non-zero features have the same value for every node). Generally, features of injected nodes should be processed using the same data processing method. I noticed that there is a commented out code in line81 if backdoor.py, which makes the feature discrete. However, the feature is not normalized before being injected into the graph.

I use F.normalise(trojan_feat, p=1, dim=1) to normalize the features in line153, line214, and line241, but find that the attack is not successful.

May I ask if I missed any other factors? Thank you for your help.

ModuleNotFoundError: No module named 'models.MedianGCN'

Hi, I met an error: 'ModuleNotFoundError: No module named 'models.MedianGCN'' when I tried to run the script. It seems that the file MedianGCN is not included in the dir 'models'. I hope you can note that.
Thank you for your help in advance.

Some questions about node selection

Hi, thanks for your work and contribution!

The structure of your code is clear, but when I read the node selection part of the code, I have some questions:

  1. why only Pubmed dataset uses cluster_degree_selection_seperate_fixed function for node selection, while the remaining three datasets use cluster_degree_selection

  2. the obtain_attach_nodes_by_cluster_degree_all function has a combination of clustering and degree, and finally uses np.argsort for ascending order (scores from low to high), which seems a bit different from the paper.
    image

Looking forward to your reply.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.