{"id":18206609,"url":"https://github.com/willyfh/graph-transformer","last_synced_at":"2025-06-12T05:07:32.879Z","repository":{"id":65586239,"uuid":"589947999","full_name":"willyfh/graph-transformer","owner":"willyfh","description":"An unofficial implementation of Graph Transformer (Masked Label Prediction: Unified Message Passing Model for Semi-Supervised Classification) - IJCAI 2021","archived":false,"fork":false,"pushed_at":"2024-04-20T11:07:38.000Z","size":495,"stargazers_count":33,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-03T02:10:12.491Z","etag":null,"topics":["deep-learning","gnn","graph-deep-learning","graph-neural-networks","graph-transformer","neural-networks","pytorch"],"latest_commit_sha":null,"homepage":"https://www.ijcai.org/proceedings/2021/0214.pdf","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/willyfh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-01-17T10:13:47.000Z","updated_at":"2025-05-28T07:20:11.000Z","dependencies_parsed_at":"2024-04-20T11:32:40.498Z","dependency_job_id":"82fd4aa3-8061-4b43-bb94-d52dceba2ae5","html_url":"https://github.com/willyfh/graph-transformer","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/willyfh/graph-transformer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willyfh%2Fgraph-transformer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willyfh%2Fgraph-transformer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willyfh%2Fgraph-transformer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willyfh%2Fgraph-transformer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willyfh","download_url":"https://codeload.github.com/willyfh/graph-transformer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willyfh%2Fgraph-transformer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259402061,"owners_count":22851870,"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":["deep-learning","gnn","graph-deep-learning","graph-neural-networks","graph-transformer","neural-networks","pytorch"],"created_at":"2024-11-03T12:05:31.248Z","updated_at":"2025-06-12T05:07:32.849Z","avatar_url":"https://github.com/willyfh.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Graph Transformer (IJCAI 2021)\n\n[![python](https://img.shields.io/badge/python-3.8%2B-blue)]() [![pytorch](https://img.shields.io/badge/pytorch-1.6%2B-orange)]() [![Downloads](https://static.pepy.tech/personalized-badge/graph-transformer?period=total\u0026units=international_system\u0026left_color=grey\u0026right_color=green\u0026left_text=PyPI%20Downloads)](https://pepy.tech/project/graph-transformer)\n\nAn unofficial implementation of Graph Transformer:\u003cbr/\u003e\nMasked Label Prediction: Unified Message Passing Model for Semi-Supervised Classification) - IJCAI 2021 \u003e https://www.ijcai.org/proceedings/2021/0214.pdf\n\nThis GNN architecture is implemented based on Section 3.1 (Graph Transformer) in the paper.\n\nI implemented the code by referring to [this repository](https://github.com/lucidrains/graph-transformer-pytorch), but with some modifications to match with the original published paper in IJCAI 2021.\n\n![image](https://github.com/willyfh/graph-transformer/blob/main/graph-transformer-architecture.png?raw=true)\n\n## Installation\n\n```bash\npip install graph-transformer\n```\n## Usage\n```python\nimport torch\nfrom graph_transformer import GraphTransformerModel\n\nmodel = GraphTransformerModel(\n        node_dim = 512,\n        edge_dim = 512,\n        num_blocks = 3, # number of graph transformer blocks\n        num_heads = 8,\n        last_average=True, # wether to average or concatenation at the last block\n        model_dim=None # if None, node_dim will be used as the dimension of the graph transformer block\n)\n\nnodes = torch.randn(1, 128, 512)\nedges = torch.randn(1, 128, 128, 512)\nadjacency = torch.ones(1, 128, 128)\n\nnodes = model(nodes, edges, adjacency)\n```\n\n**Note**: If your graph does not have edge features, you can set `edge_dim` and `edges` (in the forward pass) to `None`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillyfh%2Fgraph-transformer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillyfh%2Fgraph-transformer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillyfh%2Fgraph-transformer/lists"}