Skip to main content

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:

  1. Random Node Drop
  2. Random Edge Drop
  3. Normalize Features
  4. MixUp Strategy
  5. Node Feature Masking
  6. 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

MIT

Metadata

Release files for grafog 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grafog 0.1
File Size Uploaded Provenance Actions
grafog-0.1.tar.gz 3.8 kB Without provenance Details for grafog-0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for grafog 0.1
File Interpreter ABI Platform Actions
grafog-0.1-py3-none-any.whl Python 3 none any Details for grafog-0.1-py3-none-any.whl

Total release size: 8.3 kB

Release files / grafog-0.1.tar.gz

Download URL grafog-0.1.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
51ab2fbbeb3c24f8374ac609173726644a9e2f40705781d2bad44aaa260508dd
BLAKE2b-256 checksum
How to use checksums
9ff02008286ecd0cdeb90cff7073c1b1860cc49ecd90b585c8ddc58a941e3053
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / grafog-0.1-py3-none-any.whl

Download URL grafog-0.1-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bed8e8301bc943fe626bcdb9b2452df361fd251e88daaa86587b1c403da5330c
BLAKE2b-256 checksum
How to use checksums
3d06bd0eb150914f15d8c15c1f26d20e6467e23757d9b22be9bb2b4a8d10383c
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for grafog 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page