This repository contains a PyTorch implementation of the work "Rethinking Spectral Graph Neural Networks with Spatially Adaptive Filtering".
- pytorch 1.8.0
- numpy 1.19.5
- torch-geometric 1.7.2
- scipy 1.5.3
- seaborn 0.11.2
- sklearn 0.24.2
- pickle 4.0
- optuna (for hyper-parameter search)
We provide one dataset in the folder './data'. Other datasets can be downloaded through the links provided in the Appendix.
Run the script below to preprocess the datasets in ./data/raw/ (the preprocessed
data will be saved in ./data/processed and ./data/eigen_dcp).
python preprocessing.py
Generate the random node-classification splits with gen_splits.py. Following the
paper, two supervision modes are produced for each dataset:
- full-supervised — 60% / 20% / 20% (train / val / test), saved as
*_denseSplits.npy - semi-supervised — 2.5% / 2.5% / 95% (train / val / test), saved as
*_sparseSplits.npy
For each mode, nb_split (default 10) independent splits are created. The training
nodes are sampled class-balanced, the validation nodes are drawn at random from the
rest, and all remaining nodes form the test set. The files are written to
./data/random_splits/ in the format expected by main.py.
python gen_splits.py --dataset squirrel --nb_split 10
(Run python preprocessing.py first, as the labels are read from the processed data.)
Use optuna_search.py to tune the model. The search space follows Sec. VI-A of the
paper: learning rate, weight decay (L2), dropout, nonlocal aggregation steps L,
scaling tau, update rate eta, and (for SAF_eps) the sparsification threshold
eps. Each trial is scored by the mean validation accuracy over the first
--n_eval_splits random splits, and the best hyper-parameters are dumped to a JSON
file (best_params.json by default).
python optuna_search.py --model SAF --dataset squirrel --sl_mode full --n_trials 100
python optuna_search.py --model SAF --dataset squirrel --sl_mode semi --n_trials 100