Skip to content

Home

gtrick is an easy-to-use Python package collecting tricks for Graph Neural Networks. It tests and provides powerful tricks to boost your models' performance.

Trick is all you need! (中文简介)

Library Highlights

  • Easy-to-use: All it takes is to add a few lines of code to apply a powerful trick, with as little changes of existing code as possible.

  • Verified Trick: All tricks implemented in gtrick are tested on our selected datasets. Only the tricks indeed improving model's performance can be collected by gtrick.

  • Backend Free: We provide all tricks both in DGL and PyG. Whatever graph learning library you use, feel free to try it.

Installation

Warning

This is a developmental release.

You can install gtrick by pip:

pip install gtrick

Usage Example

It is very easy to get start with gtrick. Suppose you have a model for node classification:

from torch_geometric.nn import GCNConv
from torch_geometric.datasets import TUDataset


dataset = TUDataset(name='ENZYMES')
data = dataset[0]
model = GCNConv(dataset.num_node_features, dataset.num_classes)

out = model(data.x, data.edge_index)

You can enhance your GNN model with only a few lines of code:

from torch_geometric.nn import GCNConv
from torch_geometric.datasets import TUDataset
from gtrick import random_feature

dataset = TUDataset(name='ENZYMES')
data = dataset[0]
model = GCNConv(dataset.num_node_features, dataset.num_classes)
h = random_feature(data.x)
out = model(h, data.edge_index)

Implemented Tricks

Trick Example Task Reference
VirtualNode DGL
PyG
graph OGB Graph Property Prediction Examples
FLAG DGL
PyG
node*
graph
Robust Optimization as Data Augmentation for Large-scale Graphs
Fingerprint DGL
PyG
molecular graph* Extended-Connectivity Fingerprints
Random Feature DGL
PyG
graph* Random Features Strengthen Graph Neural Networks
Label Propagation DGL
PyG
node* Learning from Labeled and Unlabeled Datawith Label Propagation
Correct & Smooth DGL
PyG
node* Combining Label Propagation And Simple Models Out-performs Graph Neural Networks
Common Neighbors DGL
PyG
link* Link Prediction with Structural Information
Resource Allocation DGL
PyG
link* Link Prediction with Structural Information
Adamic Adar DGL
PyG
link* Link Prediction with Structural Information
Anchor Distance DGL
PyG
link* Link Prediction with Structural Information