ProNoG

March 24, 2025 ยท View on GitHub

We provide the code (in pytorch) and datasets for our paper "Non-Homophilic Graph Pre-Training and Prompt Learning", which is accepted by SIGKDD 2025.

UPDATE for running the codes

Run node classification first and then graph classification. For heterophily datasets, run execute_hetero_NC.py first. Two csv files "neighbors.csv", "neighbors_2hops.csv" will be generated and saved to speed up for other excutions. Otherwise, use find_2hop_neighbors function from utils.process file to generate neighbors and neighbors_2hops. For PROTEINS dataset, We use 1-shot dataset from MultiGPrompt as test set and 5-shot dataset as test set for ENZYMES. Related "neighbors.csv", "neighbors_2hops.csv" are provided in the relevant few_shot data folder (Download them from Google Drive, see detils below ).

Feel free to email us you have any questions.

Description

The repository is organised as follows:

  • data: data folder contains data we use in all experiments.
  • GP/graphcl/DSSL/models: this four folders contain four model architectures for respective pretraining tasks specified in the paper.
  • modelset: modelset folder contains all pretrained model checkpoints.
  • downprompt: downprompt_metanet.py contains the codes for our condition-net implementations.
  • preprompt: preprompt_new1.py is the main code for pretraining.

Package Dependencies

  • python 3.8.16
  • pytorch 1.10.1
  • cuda 12.1
  • pyG 2.1.0
  • dgl 2.1.0+cu121

Running experiments

Download data from the link: https://drive.google.com/drive/folders/1v5uEzpM1TytrgbdAwzyD_wU7A4n_NJzh?usp=drive_link and put into data folder. Change dataset name and pretrained_model parameters in python files to run the codes on different datasets. All pretrained model checkpoints can be found under modelset folder.

General settings Optimizer

For all experiments, we use the Adam optimizer.

Environment

  • The environment in which we run experiments is: Linux version: 5.15.0-78-generic
  • Operating system: Ubuntu 18.04.5 LTS
  • CPUinformation: Intel(R)Xeon(R) Platinum 8352V
  • GPU information: GeForce RTX 4090 (24 GB)

Node Classification

  1. Homophily datasets: run Python files whose names contain the strings 'homo' and 'NC'. e.g. python execute_homo_NC.py
  2. Heterophily datasets: run Python files whose names contain the strings 'hetero' and 'NC'. e.g. python execute_hetero_NC.py

You can change the dataset parameter to train and evaluate on other datasets. You can excuate the codes for both pretraining and downstream prompting, otherwise, please refer to pretraining codes under pretrain_backup folder.

Especially, we pretrained DSSL for ENZYMES. Please go to DSSL folder to implement the pretraining and downstream prompting (i.e. ENZYMES_pretrain.py, ENZYMES_prompt_NC.py, ENZYMES_prompt_GC.py).

Graph Classification

  1. Homophily datasets: run Python files whose names contain the strings 'homo' and 'GC'. e.g. python execute_homo_GC.py
  2. Heterophily datasets: run Python files whose names contain the strings 'heteo' and 'GC'. e.g. python execute_hetero_GC.py