{"id":13689400,"url":"https://github.com/benedekrozemberczki/ClusterGCN","last_synced_at":"2025-05-01T23:34:29.350Z","repository":{"id":37470222,"uuid":"192405566","full_name":"benedekrozemberczki/ClusterGCN","owner":"benedekrozemberczki","description":"A PyTorch implementation of \"Cluster-GCN: An Efficient Algorithm for Training Deep and Large Graph Convolutional Networks\" (KDD 2019).","archived":false,"fork":false,"pushed_at":"2022-11-06T21:13:53.000Z","size":14921,"stargazers_count":781,"open_issues_count":4,"forks_count":135,"subscribers_count":20,"default_branch":"master","last_synced_at":"2024-08-03T15:17:45.153Z","etag":null,"topics":["clustering","community-detection","deep-learning","deepwalk","diff2vec","gcn","gemsec","graph-clustering","graph-convolution","graph-convolutional-networks","graph-neural-networks","graph2vec","graphsage","louvain","metis","musae","neural-network","node-classification","node2vec","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benedekrozemberczki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["benedekrozemberczki"]}},"created_at":"2019-06-17T19:22:40.000Z","updated_at":"2024-07-22T03:51:46.000Z","dependencies_parsed_at":"2023-01-21T12:01:00.226Z","dependency_job_id":null,"html_url":"https://github.com/benedekrozemberczki/ClusterGCN","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedekrozemberczki%2FClusterGCN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedekrozemberczki%2FClusterGCN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedekrozemberczki%2FClusterGCN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedekrozemberczki%2FClusterGCN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benedekrozemberczki","download_url":"https://codeload.github.com/benedekrozemberczki/ClusterGCN/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224282271,"owners_count":17285798,"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":["clustering","community-detection","deep-learning","deepwalk","diff2vec","gcn","gemsec","graph-clustering","graph-convolution","graph-convolutional-networks","graph-neural-networks","graph2vec","graphsage","louvain","metis","musae","neural-network","node-classification","node2vec","pytorch"],"created_at":"2024-08-02T15:01:46.351Z","updated_at":"2024-11-12T13:31:44.788Z","avatar_url":"https://github.com/benedekrozemberczki.png","language":"Python","funding_links":["https://github.com/sponsors/benedekrozemberczki"],"categories":["图卷积网络","Paper implementations｜论文实现","Python","Paper implementations"],"sub_categories":["网络服务_其他","Other libraries｜其他库:","Other libraries:"],"readme":"ClusterGCN\n========\n[![Arxiv](https://img.shields.io/badge/ArXiv-1905.07953-orange.svg?color=blue)](https://arxiv.org/abs/1905.07953) [![codebeat badge](https://codebeat.co/badges/f7212651-50c6-40bd-9f4c-030ea56f43d3)](https://codebeat.co/projects/github-com-benedekrozemberczki-clustergcn-master)\n [![repo size](https://img.shields.io/github/repo-size/benedekrozemberczki/ClusterGCN.svg)](https://github.com/benedekrozemberczki/ClusterGCN/archive/master.zip) [![benedekrozemberczki](https://img.shields.io/twitter/follow/benrozemberczki?style=social\u0026logo=twitter)](https://twitter.com/intent/follow?screen_name=benrozemberczki)\n\nA PyTorch implementation of \"Cluster-GCN: An Efficient Algorithm for Training Deep and Large Graph Convolutional Networks\" (KDD 2019).\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"600\" src=\"clustergcn.jpg\"\u003e\n\u003c/p\u003e\n\n### Abstract\n\n\u003cp align=\"justify\"\u003e\nGraph convolutional network (GCN) has been successfully applied to many graph-based applications; however, training a large-scale GCN remains challenging. Current SGD-based algorithms suffer from either a high computational cost that exponentially grows with number of GCN layers, or a large space requirement for keeping the entire graph and the embedding of each node in memory. In this paper, we propose Cluster-GCN, a novel GCN algorithm that is suitable for SGD-based training by exploiting the graph clustering structure. Cluster-GCN works as the following: at each step, it samples a block of nodes that associate with a dense subgraph identified by a graph clustering algorithm, and restricts the neighborhood search within this subgraph. This simple but effective strategy leads to significantly improved memory and computational efficiency while being able to achieve comparable test accuracy with previous algorithms. To test the scalability of our algorithm, we create a new Amazon2M data with 2 million nodes and 61 million edges which is more than 5 times larger than the previous largest publicly available dataset (Reddit). For training a 3-layer GCN on this data, Cluster-GCN is faster than the previous state-of-the-art VR-GCN (1523 seconds vs 1961 seconds) and using much less memory (2.2GB vs 11.2GB). Furthermore, for training 4 layer GCN on this data, our algorithm can finish in around 36 minutes while all the existing GCN training algorithms fail to train due to the out-of-memory issue. Furthermore, Cluster-GCN allows us to train much deeper GCN without much time and memory overhead, which leads to improved prediction accuracy -- using a 5-layer Cluster-GCN, we achieve state-of-the-art test F1 score 99.36 on the PPI dataset, while the previous best result was 98.71.\u003c/p\u003e\n\nThis repository provides a PyTorch implementation of ClusterGCN as described in the paper:\n\n\u003e Cluster-GCN: An Efficient Algorithm for Training Deep and Large Graph Convolutional Networks\n\u003e Wei-Lin Chiang, Xuanqing Liu, Si Si, Yang Li, Samy Bengio, Cho-Jui Hsieh.\n\u003e KDD, 2019.\n\u003e [[Paper]](https://arxiv.org/abs/1905.07953)\n\n### Requirements\nThe codebase is implemented in Python 3.5.2. package versions used for development are just below.\n```\nnetworkx           1.11\ntqdm               4.28.1\nnumpy              1.15.4\npandas             0.23.4\ntexttable          1.5.0\nscipy              1.1.0\nargparse           1.1.0\ntorch              0.4.1\ntorch-geometric    0.3.1\nmetis              0.2a.4\nscikit-learn       0.20\ntorch_spline_conv  1.0.4\ntorch_sparse       0.2.2\ntorch_scatter      1.0.4\ntorch_cluster      1.1.5\n```\n\nInstalling metis on Ubuntu:\n\n```\nsudo apt-get install libmetis-dev\n```\n### Datasets\n\u003cp align=\"justify\"\u003e\nThe code takes the **edge list** of the graph in a csv file. Every row indicates an edge between two nodes separated by a comma. The first row is a header. Nodes should be indexed starting with 0. A sample graph for `Pubmed` is included in the  `input/` directory. In addition to the edgelist there is a csv file with the sparse features and another one with the target variable.\u003c/p\u003e\n\u003cp align=\"justify\"\u003e\nThe **feature matrix** is a sparse one and it is stored as a csv. Features are indexed from 0 consecutively. The feature matrix csv is structured as:\u003c/p\u003e\n\n| **NODE ID**|**FEATURE ID**|**Value** |\n| --- | --- |---|\n| 0 | 3 |0.2|\n| 0 | 7 | 0.5 |\n| 1 | 17 | 0.8 |\n| 1 | 4 | 5.4 |\n| 1 | 38 | 1.3 |\n| ... | ... |...|\n| n | 3 | 0.9 |\n\u003cp align=\"justify\"\u003e\nThe **target vector** is a csv with two columns and headers, the first contains the node identifiers the second the targets. This csv is sorted by node identifiers and the target column contains the class meberships indexed from zero.\u003c/p\u003e\n\n| **NODE ID**|**Target** |\n| --- | --- |\n| 0 | 3 |\n| 1 | 1 |\n| 2 | 0 |\n| 3 | 1 |\n| ... | ... |\n| n | 3 |\n\n### Options\n\u003cp align=\"justify\"\u003e\nThe training of a ClusterGCN model is handled by the `src/main.py` script which provides the following command line arguments.\u003c/p\u003e\n\n#### Input and output options\n```\n  --edge-path       STR    Edge list csv.         Default is `input/edges.csv`.\n  --features-path   STR    Features csv.         Default is `input/features.csv`.\n  --target-path     STR    Target classes csv.    Default is `input/target.csv`.\n```\n#### Model options\n```\n  --clustering-method   STR     Clustering method.             Default is `metis`.\n  --cluster-number      INT     Number of clusters.            Default is 10. \n  --seed                INT     Random seed.                   Default is 42.\n  --epochs              INT     Number of training epochs.     Default is 200.\n  --test-ratio          FLOAT   Training set ratio.            Default is 0.9.\n  --learning-rate       FLOAT   Adam learning rate.            Default is 0.01.\n  --dropout             FLOAT   Dropout rate value.            Default is 0.5.\n  --layers              LST     Layer sizes.                   Default is [16, 16, 16]. \n```\n### Examples\n\u003cp align=\"justify\"\u003e\nThe following commands learn a neural network and score on the test set. Training a model on the default dataset.\u003c/p\u003e\n\n```sh\n$ python src/main.py\n```\n\u003cp align=\"center\"\u003e\n\u003cimg style=\"float: center;\" src=\"clustergcn.gif\"\u003e\n\u003c/p\u003e\n\nTraining a ClusterGCN model for a 100 epochs.\n```sh\n$ python src/main.py --epochs 100\n```\nIncreasing the learning rate and the dropout.\n```sh\n$ python src/main.py --learning-rate 0.1 --dropout 0.9\n```\nTraining a model with a different layer structure:\n```sh\n$ python src/main.py --layers 64 64\n```\nTraining a random clustered model:\n```sh\n$ python src/main.py --clustering-method random\n```\n\n\n----------------------\n\n**License**\n\n- [GNU](https://github.com/benedekrozemberczki/ClusterGCN/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenedekrozemberczki%2FClusterGCN","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenedekrozemberczki%2FClusterGCN","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenedekrozemberczki%2FClusterGCN/lists"}