A PyTorch implementation of "Graph Classification Using Structural Attention" (KDD 2018).
GPL-3.0 License
A PyTorch implementation of Graph Classification Using Structural Attention (KDD 2018).
This repository provides an implementation for GAM as described in the paper:
Graph Classification using Structural Attention. John Boaz Lee, Ryan Rossi, and Xiangnan Kong KDD, 2018. [Paper]
The codebase is implemented in Python 3.5.2. package versions used for development are just below.
networkx 2.4
tqdm 4.28.1
numpy 1.15.4
pandas 0.23.4
texttable 1.5.0
argparse 1.1.0
sklearn 0.20.0
torch 1.2.0.
torchvision 0.3.0
For example these JSON files have the following key-value structure:
{"target": 1,
"edges": [[0, 1], [0, 4], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]],
"labels": {"0": 2, "1": 3, "2": 2, "3": 3, "4": 4},
"inverse_labels": {"2": [0, 2], "3": [1, 3], "4": [4]}}
Training a GAM model is handled by the src/main.py
script which provides the following command line arguments.
--train-graph-folder STR Training graphs folder. Default is `input/train/`.
--test-graph-folder STR Testing graphs folder. Default is `input/test/`.
--prediction-path STR Path to store labels. Default is `output/erdos_predictions.csv`.
--log-path STR Log json path. Default is `logs/erdos_gam_logs.json`.
--repetitions INT Number of scoring runs. Default is 10.
--batch-size INT Number of graphs processed per batch. Default is 32.
--time INT Time budget. Default is 20.
--step-dimensions INT Neurons in step layer. Default is 32.
--combined-dimensions INT Neurons in shared layer. Default is 64.
--epochs INT Number of GAM training epochs. Default is 10.
--learning-rate FLOAT Learning rate. Default is 0.001.
--gamma FLOAT Discount rate. Default is 0.99.
--weight-decay FLOAT Weight decay. Default is 10^-5.
Training a GAM model on the default dataset. Saving predictions and logs at default paths.
python src/main.py
Training a GAM model for a 100 epochs with a batch size of 512.
python src/main.py --epochs 100 --batch-size 512
Setting a high time budget for the agent.
python src/main.py --time 128
Training a model with some custom learning rate and epoch number.
python src/main.py --learning-rate 0.001 --epochs 200
License