Official implementation of "HGNN Shield: Defending Hypergraph Neural Networks Against High-Order Structure Attack", published in IEEE Transactions on Pattern Analysis and Machine Intelligence (TPAMI).
Authors: Yifan Feng, Yifan Zhang, Shaoyi Du, Shihui Ying, Jun-Hai Yong, Yue Gao
Figure 1: The architecture of HGNN Shield framework.
HGNN Shield is a robust framework designed to defend Hypergraph Neural Networks (HGNNs) against sophisticated high-order structure attacks. Unlike traditional graph-based defenses, HGNN Shield focuses on the unique properties of hyperedges to identify and purify malicious structural perturbations.
- Structural Purification: Automatically identifies and prunes abnormal connections in hyperedges using feature-consistency analysis.
- Adaptive Re-linking: Recovers potential valid relationships by establishing new connections for pruned nodes based on local similarity.
- Versatile Backbone Support: Compatible with various GNN and HGNN architectures.
- Python 3.10+
- PyTorch 1.12+
- dhg (DeepHypergraph)
- DeepRobust
pip install torch dhg deeprobust hydra-core omegaconfWe provide the pre-processed attacked data on Google Drive.
Place the data files under specified root directory:
data/
└── coauthorship_cora/
└── [mode]/
└── [attack_rate]/
└── data.pt
Configure the attack section in config/config.yaml and run:
python attack.pyAll hyperparameters and configurations are managed via Hydra in config/config.yaml.
To train HGNN Shield on the default dataset:
python train.pyKey parameters in config/config.yaml:
model.threshold: Pruning threshold for structural purification (Default: 0.05).model.threshold2: Linking threshold for node recovery (Default: 0.015).attack.rate: Perturbation intensity (e.g., 0.1, 0.2).
Run ablation tasks (e.g., sensitivity analysis of thresholds):
python ablation.pyHGNN Shield demonstrates superior robustness across various benchmarks and attack scenarios.
Figure 2: Performance under non-targeted and targeted attacks.
If you find this repository or our research helpful, please consider citing our TPAMI paper:
@ARTICLE{feng2024hgnnshield,
author={Feng, Yifan and Zhang, Yifan and Du, Shaoyi and Ying, Shihui and Yong, Jun-Hai and Gao, Yue},
journal={IEEE Transactions on Pattern Analysis & Machine Intelligence},
title={{ HGNN Shield: Defending Hypergraph Neural Networks Against High-Order Structure Attack }},
year={2026},
volume={},
number={01},
ISSN={1939-3539},
pages={1-17},
}For any questions, please contact yifanfeng@tsinghua.edu.cn.