https://github.com/graph-com/spe
Official code for SPE
https://github.com/graph-com/spe
Last synced: 6 months ago
JSON representation
Official code for SPE
- Host: GitHub
- URL: https://github.com/graph-com/spe
- Owner: Graph-COM
- Created: 2023-10-03T23:21:42.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-09-15T09:16:02.000Z (over 1 year ago)
- Last Synced: 2024-09-15T11:55:36.972Z (over 1 year ago)
- Language: Python
- Size: 246 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# On the Expressivity of Stable Positional Encodings for Graphs
## About
This is the official code for the paper: [On the Expressivity of Stable Positional Encodings for Graphs](https://arxiv.org/abs/2310.02579).
Feel free to contact yinan8114@gmail.com if there is any question.

## Introduction
In this work, we present SPE, a Laplacian-based graph positional encodings that are provably stable and expressive. The key insight is to perform a **soft and learnable** ``partition" of eigensubspaces in an **eigenvalue dependent** way, hereby achieving both stability (from the soft partition) and expressivity (from dependency on both eigenvalues and eigenvectors).
Our SPE method processes eigenvectors $V\in\mathbb{R}^{n\times d}$ and eigenvalues $\lambda\in\mathbb{R}^d$ into node positional encodings as follows:
$$\text{SPE}(V, \lambda)=\rho(V\text{diag}\{\phi_1(\lambda)\}V^{T}, V\text{diag}\{\phi_2(\lambda)\}V^{T}, ..., V\text{diag}\{\phi_m(\lambda)\}V^{T}),$$
where $\rho:\mathbb{R}^{n\times n\times m}\to\mathbb{R}^{n\times p}$ and $\phi_i:\mathbb{R}^{d}\to\mathbb{R}^d$ are permutational equivariant functions w.r.t. $n\times n$ and $d$ axes respectively.
## Code usage
### Requirements
See requirements.txt for necessary python environment.
### Dataset
Download all required datasets from [here](https://drive.google.com/drive/folders/17nVALCgTz0LV8pVuoM0xQnRqwRH3Bz7a?usp=drive_link). The downloaded 'data' directory should be placed in the root direcotry. For example, './data/drugood', etc.
### Reproduce experiments
To reproduce experiments on ZINC, cd to ./zinc and run
```
python runner.py --config_dirpath ../configs/zinc --config_name SPE_gine_gin_mlp_pe37.yaml --seed 0
```
To reproduce experiments on Alchemy, cd to ./alchemy and run
```
python --config_dirpath ../configs/alchemy --config_name SPE_gine_gin_mlp_pe12.yaml --seed 0
```
To reproduce experiments on DrugOOD, cd to ./drugood and run
```
python --config_dirpath ../configs/assay --config_name SPE_gine_gin_mlp_pe32_zeropsi.yaml --dataset assay --seed 0
python --config_dirpath ../configs/scaffold --config_name SPE_gine_gin_mlp_pe32_standard_dropout.yaml --dataset scaffold --seed 0
python --config_dirpath ../configs/scaffold --config_name SPE_gine_gin_mlp_pe32_standard_dropout.yaml --dataset size --seed 0
```
To reproduce substructures counting, cd to ./count and run
```
bash run.sh
```