{"id":13677970,"url":"https://github.com/rish-16/grafog","last_synced_at":"2025-08-08T13:17:18.410Z","repository":{"id":47194035,"uuid":"440525758","full_name":"rish-16/grafog","owner":"rish-16","description":"Graph Data Augmentation Library for PyTorch Geometric","archived":false,"fork":false,"pushed_at":"2022-08-17T06:55:45.000Z","size":102,"stargazers_count":132,"open_issues_count":0,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-06-01T10:13:41.556Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rish-16.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-21T13:26:35.000Z","updated_at":"2025-05-04T11:09:06.000Z","dependencies_parsed_at":"2022-08-17T07:30:25.097Z","dependency_job_id":null,"html_url":"https://github.com/rish-16/grafog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rish-16/grafog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rish-16%2Fgrafog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rish-16%2Fgrafog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rish-16%2Fgrafog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rish-16%2Fgrafog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rish-16","download_url":"https://codeload.github.com/rish-16/grafog/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rish-16%2Fgrafog/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261990349,"owners_count":23241189,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T13:00:48.974Z","updated_at":"2025-06-26T03:06:04.415Z","avatar_url":"https://github.com/rish-16.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"\u003cimg src=\"banner.png\"\u003e\n\n# grafog\nGraph Data Augmentation Library for PyTorch Geometric.\n\n---\n\n## What is it?\nData 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. \n\n`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`](https://pytorch-geometric.readthedocs.io/en/latest/modules/data.html#torch_geometric.data.Data) API.\n\n\u003e Yannic Kilcher talks about it here: [https://youtu.be/smUHQndcmOY?t=961](https://youtu.be/smUHQndcmOY?t=961)\n\n---\n\n## Installation\nYou can install the library via `pip`:\n\n```\n$ pip install grafog\n```\n\nYou can also install the library from source:\n\n```\n$ git clone https://github.com/rish-16/grafog\n$ cd grafog\n$ pip install -e .\n```\n\n#### Dependencies\n```\ntorch==1.10.2\ntorch_geometric==2.0.3\n```\n---\n\n## Usage\nThe library comes with the following data augmentations:\n\n| Augmentation                 | Remarks                                            | When to use              |\n|------------------------------|----------------------------------------------------|--------------------------|\n| `NodeDrop(p=0.05)`           | Randomly drops nodes with the given `p`            | before, during training  |\n| `EdgeDrop(p=0.05)`           | Randomly drops edges with the given `p`            | before, during training  |\n| `Normalize()`                | Normalizes the node or edge features               | before training          |\n| `NodeMixUp(lamb, classes)`   | MixUp on node features with given lambda           | during training          |\n| `NodeFeatureMasking(p=0.15)` | Randomly masks node features with the given `p`    | during training          |\n| `EdgeFeatureMasking(p=0.15)` | Randomly masks edge features with the given `p`    | during training          |\n\n\u003e There are many more features to be added over time, so stay tuned!\n\n```python\nfrom torch_geometric.datasets import CoraFull\nimport grafog.transforms as T\n\nnode_aug = T.Compose([\n    T.NodeDrop(p=0.45),\n    T.NodeMixUp(lamb=0.5, classes=7),\n    ...\n])\n\nedge_aug = T.Compose([\n    T.EdgeDrop(0=0.15),\n    T.EdgeFeatureMasking()\n])\n\ndata = CoraFull()\nmodel = ...\n\nfor epoch in range(10): # begin training loop\n    new_data = node_aug(data) # apply the node augmentation(s)\n    new_data = edge_aug(new_data) # apply the edge augmentation(s)\n    \n    x, y = new_data.x, new_data.y\n    ...\n```\n\n---\n\n## Remarks\nThis library was built as a project for a class ([UIT2201](https://nusmods.com/modules/UIT2201/computer-science-the-i-t-revolution)) at NUS. I planned and built it over the span of 10 weeks. I thank _Prof. Mikhail Filippov_ for his guidance, feedback, and support!\n\nIf you spot any issues, feel free to raise a PR or Issue. All meaningful contributions welcome!\n\n---\n\n## License\n[MIT](https://github.com/rish-16/grafog/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frish-16%2Fgrafog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frish-16%2Fgrafog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frish-16%2Fgrafog/lists"}