Graph Data Augmentations for PyTorch Geometric
Project description
grafog
Graph Data Augmentation Library for PyTorch Geometric.
What is it?
Data augmentations are heavily used in Computer Vision and Natural Language Processing to address data imbalance, data scarcity, and prevent models from overfitting. They have also proven to yield good results in both supervised and self-supervised (contrastive) settings.
grafog
(portmanteau of "graph" and "augmentation") provides a set of methods to perform data augmentation on graph-structured data, especially meant for self-supervised node classification. It is built on top of torch_geometric
and is easily integrable with its Data
API.
Installation
You can install the library via pip
:
$ pip install grafog
You can also install the library from source:
$ git clone https://github.com/rish-16/grafog
$ cd grafog
$ pip install -e .
Dependencies
torch==1.10.2
torch_geometric==2.0.3
Usage
The library comes with the following data augmentations:
- Random Node Drop
- Random Edge Drop
- Normalize Features
- MixUp Strategy
- Node Feature Masking
- Edge Feature Masking
There are many more features to be added over time, so stay tuned!
from torch_geometric.datasets import CoraFull
import grafog.transforms as T
node_aug = T.Compose([
T.NodeDrop(p=0.45),
T.NodeMixUp(lamb=0.5, classes=7),
...
])
edge_aug = T.Compose([
T.EdgeDrop(0=0.15),
T.EdgeFeatureMasking()
])
data = CoraFull()
model = ...
for epoch in range(10): # begin training loop
new_data = node_aug(data) # apply the node augmentation(s)
new_data = edge_aug(new_data) # apply the edge augmentation(s)
x, y = new_data.x, new_data.y
...
Remarks
This library was built as a project for a class (UIT2201) at NUS. I planned and built it over the span of 10 weeks. I thank Prof. Mikhail Filippov for his guidance, feedback, and support!
If you spot any issues, feel free to raise a PR or Issue. All meaningful contributions welcome!
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file grafog-0.1.tar.gz
.
File metadata
- Download URL: grafog-0.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51ab2fbbeb3c24f8374ac609173726644a9e2f40705781d2bad44aaa260508dd |
|
MD5 | 9d447c819f87de47110910059565baaa |
|
BLAKE2b-256 | 9ff02008286ecd0cdeb90cff7073c1b1860cc49ecd90b585c8ddc58a941e3053 |
File details
Details for the file grafog-0.1-py3-none-any.whl
.
File metadata
- Download URL: grafog-0.1-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bed8e8301bc943fe626bcdb9b2452df361fd251e88daaa86587b1c403da5330c |
|
MD5 | 4c1a7529b08f0d04e3544bf971096f18 |
|
BLAKE2b-256 | 3d06bd0eb150914f15d8c15c1f26d20e6467e23757d9b22be9bb2b4a8d10383c |