forked from graphdeeplearning/graphtransformer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3ca2394
Showing
66 changed files
with
4,509 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#common | ||
**/*.DS_Store | ||
**/*.ipynb_checkpoints/ | ||
**/__pycache__ | ||
out/ | ||
|
||
gmail.py | ||
|
||
#SBM datasets | ||
data/SBMs/*.pkl | ||
|
||
#Superpixels datasets | ||
data/superpixels/*.pkl | ||
data/superpixels/*.zip | ||
PATH/ | ||
|
||
#ZINC dataset | ||
data/molecules/*.pkl | ||
data/molecules/*.pickle | ||
data/molecules/*.zip | ||
data/molecules/zinc-full/*.pkl | ||
|
||
#TSP | ||
data/TSP/*.txt | ||
data/TSP/*.pkl | ||
data/TSP/*.zip | ||
data/TSP/pyconcorde/ | ||
|
||
#COLLAB | ||
data/COLLAB/* | ||
dataset/ | ||
|
||
#CSL | ||
data/CSL/*.pkl | ||
data/CSL/*.zip | ||
data/CSL/*.pt | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Vijay Prakash Dwivedi, Xavier Bresson | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
|
||
|
||
# Graph Transformer Architecture | ||
|
||
Source code for the paper "**A Generalization of Transformer Networks to Graphs**" by _[Vijay Prakash Dwivedi](https://github.com/vijaydwivedi75) and [Xavier Bresson](https://github.com/xbresson)_, at **AAAI'21 Workshop on Deep Learning on Graphs: Methods and Applications (DLG-AAAI'21)**. | ||
|
||
We propose a generalization of transformer neural network architecture for arbitrary graphs: **Graph Transformer**. <br>Compared to the [Standard Transformer](https://papers.nips.cc/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf), the highlights of the presented architecture are: | ||
|
||
- The attention mechanism is a function of neighborhood connectivity for each node in the graph. | ||
- The position encoding is represented by Laplacian eigenvectors, which naturally generalize the sinusoidal positional encodings often used in NLP. | ||
- The layer normalization is replaced by a batch normalization layer. | ||
- The architecture is extended to have edge representation, which can be critical to tasks with rich information on the edges, or pairwise interactions (such as bond types in molecules, or relationship type in KGs. etc). | ||
|
||
<br> | ||
|
||
<p align="center"> | ||
<img src="./docs/graph_transformer.png" alt="Graph Transformer Architecture" width="800"> | ||
<br> | ||
<b>Figure</b>: Block Diagram of Graph Transformer Architecture | ||
</p> | ||
|
||
|
||
## 1. Repo installation | ||
|
||
This project is based on the [benchmarking-gnns](https://github.com/graphdeeplearning/benchmarking-gnns) repository. | ||
|
||
[Follow these instructions](./docs/01_benchmark_installation.md) to install the benchmark and setup the environment. | ||
|
||
|
||
<br> | ||
|
||
## 2. Download datasets | ||
|
||
[Proceed as follows](./docs/02_download_datasets.md) to download the datasets used to evaluate Graph Transformer. | ||
|
||
|
||
<br> | ||
|
||
## 3. Reproducibility | ||
|
||
[Use this page](./docs/03_run_codes.md) to run the codes and reproduce the published results. | ||
|
||
|
||
<br> | ||
|
||
## 4. Reference | ||
|
||
Coming soon! | ||
|
||
<!-- ``` | ||
@article{dwivedi2020graph, | ||
title={A Generalization of Transformer Networks to Graphs}, | ||
author={Dwivedi, Vijay Prakash and and Bresson, Xavier}, | ||
journal={arXiv preprint arXiv:2012.xxxxx}, | ||
year={2020} | ||
} | ||
``` | ||
--> | ||
|
||
|
||
<br><br><br> | ||
|
41 changes: 41 additions & 0 deletions
41
configs/SBMs_GraphTransformer_CLUSTER_500k_full_graph_BN.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"gpu": { | ||
"use": true, | ||
"id": 0 | ||
}, | ||
|
||
"model": "GraphTransformer", | ||
"dataset": "SBM_CLUSTER", | ||
|
||
"out_dir": "out/SBMs_full_NoPE_BN/", | ||
|
||
"params": { | ||
"seed": 41, | ||
"epochs": 1000, | ||
"batch_size": 10, | ||
"init_lr": 0.0005, | ||
"lr_reduce_factor": 0.5, | ||
"lr_schedule_patience": 10, | ||
"min_lr": 1e-6, | ||
"weight_decay": 0.0, | ||
"print_epoch_interval": 5, | ||
"max_time": 24 | ||
}, | ||
|
||
"net_params": { | ||
"L": 10, | ||
"n_heads": 8, | ||
"hidden_dim": 80, | ||
"out_dim": 80, | ||
"residual": true, | ||
"readout": "mean", | ||
"in_feat_dropout": 0.0, | ||
"dropout": 0.0, | ||
"layer_norm": false, | ||
"batch_norm": true, | ||
"self_loop": false, | ||
"lap_pos_enc": false, | ||
"wl_pos_enc": false, | ||
"full_graph": true | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
configs/SBMs_GraphTransformer_CLUSTER_500k_full_graph_LN.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"gpu": { | ||
"use": true, | ||
"id": 0 | ||
}, | ||
|
||
"model": "GraphTransformer", | ||
"dataset": "SBM_CLUSTER", | ||
|
||
"out_dir": "out/SBMs_full_NoPE_LN/", | ||
|
||
"params": { | ||
"seed": 41, | ||
"epochs": 1000, | ||
"batch_size": 10, | ||
"init_lr": 0.0005, | ||
"lr_reduce_factor": 0.5, | ||
"lr_schedule_patience": 10, | ||
"min_lr": 1e-6, | ||
"weight_decay": 0.0, | ||
"print_epoch_interval": 5, | ||
"max_time": 24 | ||
}, | ||
|
||
"net_params": { | ||
"L": 10, | ||
"n_heads": 8, | ||
"hidden_dim": 80, | ||
"out_dim": 80, | ||
"residual": true, | ||
"readout": "mean", | ||
"in_feat_dropout": 0.0, | ||
"dropout": 0.0, | ||
"layer_norm": true, | ||
"batch_norm": false, | ||
"self_loop": false, | ||
"lap_pos_enc": false, | ||
"wl_pos_enc": false, | ||
"full_graph": true | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
configs/SBMs_GraphTransformer_CLUSTER_500k_sparse_graph_BN.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"gpu": { | ||
"use": true, | ||
"id": 0 | ||
}, | ||
|
||
"model": "GraphTransformer", | ||
"dataset": "SBM_CLUSTER", | ||
|
||
"out_dir": "out/SBMs_sparse_NoPE_BN/", | ||
|
||
"params": { | ||
"seed": 41, | ||
"epochs": 1000, | ||
"batch_size": 32, | ||
"init_lr": 0.0005, | ||
"lr_reduce_factor": 0.5, | ||
"lr_schedule_patience": 10, | ||
"min_lr": 1e-6, | ||
"weight_decay": 0.0, | ||
"print_epoch_interval": 5, | ||
"max_time": 24 | ||
}, | ||
|
||
"net_params": { | ||
"L": 10, | ||
"n_heads": 8, | ||
"hidden_dim": 80, | ||
"out_dim": 80, | ||
"residual": true, | ||
"readout": "mean", | ||
"in_feat_dropout": 0.0, | ||
"dropout": 0.0, | ||
"layer_norm": false, | ||
"batch_norm": true, | ||
"self_loop": false, | ||
"lap_pos_enc": false, | ||
"wl_pos_enc": false, | ||
"full_graph": false | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
configs/SBMs_GraphTransformer_CLUSTER_500k_sparse_graph_LN.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"gpu": { | ||
"use": true, | ||
"id": 0 | ||
}, | ||
|
||
"model": "GraphTransformer", | ||
"dataset": "SBM_CLUSTER", | ||
|
||
"out_dir": "out/SBMs_sparse_NoPE_LN/", | ||
|
||
"params": { | ||
"seed": 41, | ||
"epochs": 1000, | ||
"batch_size": 32, | ||
"init_lr": 0.0005, | ||
"lr_reduce_factor": 0.5, | ||
"lr_schedule_patience": 10, | ||
"min_lr": 1e-6, | ||
"weight_decay": 0.0, | ||
"print_epoch_interval": 5, | ||
"max_time": 24 | ||
}, | ||
|
||
"net_params": { | ||
"L": 10, | ||
"n_heads": 8, | ||
"hidden_dim": 80, | ||
"out_dim": 80, | ||
"residual": true, | ||
"readout": "mean", | ||
"in_feat_dropout": 0.0, | ||
"dropout": 0.0, | ||
"layer_norm": true, | ||
"batch_norm": false, | ||
"self_loop": false, | ||
"lap_pos_enc": false, | ||
"wl_pos_enc": false, | ||
"full_graph": false | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
configs/SBMs_GraphTransformer_LapPE_CLUSTER_500k_full_graph_BN.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"gpu": { | ||
"use": true, | ||
"id": 0 | ||
}, | ||
|
||
"model": "GraphTransformer", | ||
"dataset": "SBM_CLUSTER", | ||
|
||
"out_dir": "out/SBMs_full_LapPE_BN/", | ||
|
||
"params": { | ||
"seed": 41, | ||
"epochs": 1000, | ||
"batch_size": 10, | ||
"init_lr": 0.0005, | ||
"lr_reduce_factor": 0.5, | ||
"lr_schedule_patience": 10, | ||
"min_lr": 1e-6, | ||
"weight_decay": 0.0, | ||
"print_epoch_interval": 5, | ||
"max_time": 24 | ||
}, | ||
|
||
"net_params": { | ||
"L": 10, | ||
"n_heads": 8, | ||
"hidden_dim": 80, | ||
"out_dim": 80, | ||
"residual": true, | ||
"readout": "mean", | ||
"in_feat_dropout": 0.0, | ||
"dropout": 0.0, | ||
"layer_norm": false, | ||
"batch_norm": true, | ||
"self_loop": false, | ||
"lap_pos_enc": true, | ||
"pos_enc_dim": 10, | ||
"wl_pos_enc": false, | ||
"full_graph": true | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
configs/SBMs_GraphTransformer_LapPE_CLUSTER_500k_full_graph_LN.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"gpu": { | ||
"use": true, | ||
"id": 0 | ||
}, | ||
|
||
"model": "GraphTransformer", | ||
"dataset": "SBM_CLUSTER", | ||
|
||
"out_dir": "out/SBMs_full_LapPE_LN/", | ||
|
||
"params": { | ||
"seed": 41, | ||
"epochs": 1000, | ||
"batch_size": 10, | ||
"init_lr": 0.0005, | ||
"lr_reduce_factor": 0.5, | ||
"lr_schedule_patience": 10, | ||
"min_lr": 1e-6, | ||
"weight_decay": 0.0, | ||
"print_epoch_interval": 5, | ||
"max_time": 24 | ||
}, | ||
|
||
"net_params": { | ||
"L": 10, | ||
"n_heads": 8, | ||
"hidden_dim": 80, | ||
"out_dim": 80, | ||
"residual": true, | ||
"readout": "mean", | ||
"in_feat_dropout": 0.0, | ||
"dropout": 0.0, | ||
"layer_norm": true, | ||
"batch_norm": false, | ||
"self_loop": false, | ||
"lap_pos_enc": true, | ||
"pos_enc_dim": 10, | ||
"wl_pos_enc": false, | ||
"full_graph": true | ||
} | ||
} |
Oops, something went wrong.