GSLB


NameGSLB JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/GSL-Benchmark/GSLB
SummaryGSLB: Graph Structure Learning Benchmark
upload_time2023-07-12 13:10:27
maintainer
docs_urlNone
authorLiang Wang
requires_python>=3.8
license
keywords pytorch graph-neural-networks graph-structure-learning
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
<img src="logo.jpeg" width="100%" class="center" alt="logo"/>
</p>

# Graph Structure Learning Benchmark (GSLB)

GSLB is a Graph Structure Learning (GSL) library and benchmark based on [DGL](https://github.com/dmlc/dgl) and [PyTorch](https://pytorch.org/). We integrate diverse datasets and state-of-the-art GSL models.

## 📔 What is Graph Structure Learning?

<p align="center">
<img src="pipeline.png" width="100%" class="center" alt="pipeline"/>
</p>

Graph Structure Learning (GSL) aims to optimize both the parameters of Graph Neural Networks (GNNs) and the computation graph structure simultaneously. GSL methods start with input features and an optimal initial graph structure. Its corresponding computation graph is iteratively refined through a structure learning module. With the refined computation graph ,GNNs are used to generate graph representations. Then parameters of the GNNs and the structure modeling module are jointly updated, either simultaneously or alternatively, util a preset stopping condition is satisfied.

If you want to explore more information about GSL, please refer to our [survey](https://www.researchgate.net/profile/Yanqiao-Zhu/publication/349787551_Deep_Graph_Structure_Learning_for_Robust_Representations_A_Survey/links/6137188538818c2eaf885a3f/Deep-Graph-Structure-Learning-for-Robust-Representations-A-Survey.pdf) and [paper collection](https://github.com/zepengzhang/awesome-graph-structure-learning).

## 🚀 Get Start

### Requirements

GSLB needs the following requirements to be satisfied beforehand:

* Python 3.8+
* PyTorch 1.13
* DGL 1.1+
* Scipy 1.9+
* Scikit-learn
* Numpy
* NetworkX
* ogb
* tqdm
* easydict
* PyYAML

## Usage

If you want to quickly run an existing GSL model on a graph dataset:

```python
python main.py --dataset dataset_name --model model_name -n num_trails -g 0 --use_knn -k 5 --use_mettack --sparse --metric acc -p 0. --drop_rate 0. --add_rate 0.
```

Optional arguments:

``--dataset`` : the name of graph dataset

``--model`` : the name of GSL model

``--ntrail -n`` : repetition count of experiments

``--use_knn`` : whether to use knn graph instead of the original graph

``--k`` : the number of the nearest neighbors

``--drop_rate`` : the probability of randomly edge deletion

``--add_rate`` : the probability of randomly edge addition

``--use_mettack`` : whether to use the structure after being attacked by mettack

``--ptb_rate -p`` : the perturbation rate

``--metric`` : the evaluation metric

``--gpu_num -g`` : the selected GPU number

*Example: Train GRCN on Cora dataset, with the evaluation metric is accuracy.*

```
python main.py --dataset cora --model GRCN --metric acc
```



Step 1: Load datasets

```python
from GSL.data import *

# load a homophilic or heterophilic graph dataset
data = Dataset(root='/tmp/', name='cora')

# load a perturbed graph dataset
data = Dataset(root='/tmp/', name='cora', use_mettack=True, ptb_rate=0.05)

# load a heterogeneous graph dataset
data = HeteroDataset(root='/tmp/', name='acm')

# load a graph-level dataset
data = GraphDataset(root='/tmp/', name='IMDB-BINARY', model='GCN')
```

Step 2: Initialize the GSL model

```python
from GSL.model import *
from GSL.utils import accuracy, macro_f1, micro_f1

model_name = 'GRCN'
metric = 'acc'
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

# the hyper-parameters are recorded in config
config_path = './configs/{}_config.yaml'.format(model_name.lower())

# select a evaluation metric
eval_metric = {
  'acc': accuracy,
  'macro-f1': macro_f1,
  'micro-f1': micro_f1
}[metric]

model = GRCN(data.num_feat, data.num_class, evel_metric,
            config_path, dataset_name, device)
```

Step 3: Train GSL model

```python
model.fit(data)
```

## 🧩 Implementation Algorithms

Currently, we have implement the following GSL algorithms:

* GRCN [ECML PKDD 2020], *Graph-Revised Convolutional Network*
* ProGNN [KDD 2020], *Graph structure learning for robust graph neural networks*
* IDGL [NeurIPS 2020], *Iterative Deep Graph Learning for Graph Neural Networks: Better and Robust Node Embeddings*
* GEN [WWW 2021], *Graph Structure Estimation Neural Networks*
* CoGSL [WWW 2022], *Compact Graph Structure Learning via Mutual Information Compression*
* SLAPS [NeurIPS 2021], *SLAPS: Self-Supervision Improves Structure Learning for Graph Neural Networks*
* SUBLIME [WWW 2022], *Towards Unsupervised Deep Graph Structure Learning*
* STABLE [KDD 2022], *Reliable Representations Make A Stronger Defender: Unsupervised Structure Refinement for Robust GNN*
* NodeFormer [NeurIPS 2022], *NodeFormer: A Scalable Graph Structure Learning Transformer for Node Classification*
* HES-GSL [TNNLS 2023], *Homophily-Enhanced Self-Supervision for Graph Structure Learning: Insights and Directions*
* GTN [NeurIPS 2020], *Graph Transformer Networks*
* HGSL [AAAI 2021], *Heterogeneous Graph Structure Learning for Graph Neural Networks*
* HGP-SL [AAAI 2020], *Hierarchical Graph Pooling with Structure Learning*
* VIB-GSL [AAAI 2022], *Graph Structure Learning with Variational Information Bottleneck*

**Candidate algorithms**
* NeuralSparse [ICML 2020], *Robust Graph Representation Learning via Neural Sparsification*
* PTDNet [WSDM 2021], *Learning to Drop: Robust Graph Neural Network via Topological Denoising*

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/GSL-Benchmark/GSLB",
    "name": "GSLB",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "PyTorch,Graph-Neural-Networks,Graph-Structure-Learning",
    "author": "Liang Wang",
    "author_email": "wangliang.leon20@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/27/47/f7cc992971aa17a95a833fe998feb0775cf9a4a2e1061f26e21ecdf9c270/GSLB-0.1.0.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n<img src=\"logo.jpeg\" width=\"100%\" class=\"center\" alt=\"logo\"/>\n</p>\n\n# Graph Structure Learning Benchmark (GSLB)\n\nGSLB is a Graph Structure Learning (GSL) library and benchmark based on [DGL](https://github.com/dmlc/dgl) and [PyTorch](https://pytorch.org/). We integrate diverse datasets and state-of-the-art GSL models.\n\n## \ud83d\udcd4 What is Graph Structure Learning?\n\n<p align=\"center\">\n<img src=\"pipeline.png\" width=\"100%\" class=\"center\" alt=\"pipeline\"/>\n</p>\n\nGraph Structure Learning (GSL) aims to optimize both the parameters of Graph Neural Networks (GNNs) and the computation graph structure simultaneously. GSL methods start with input features and an optimal initial graph structure. Its corresponding computation graph is iteratively refined through a structure learning module. With the refined computation graph ,GNNs are used to generate graph representations. Then parameters of the GNNs and the structure modeling module are jointly updated, either simultaneously or alternatively, util a preset stopping condition is satisfied.\n\nIf you want to explore more information about GSL, please refer to our [survey](https://www.researchgate.net/profile/Yanqiao-Zhu/publication/349787551_Deep_Graph_Structure_Learning_for_Robust_Representations_A_Survey/links/6137188538818c2eaf885a3f/Deep-Graph-Structure-Learning-for-Robust-Representations-A-Survey.pdf) and [paper collection](https://github.com/zepengzhang/awesome-graph-structure-learning).\n\n## \ud83d\ude80 Get Start\n\n### Requirements\n\nGSLB needs the following requirements to be satisfied beforehand:\n\n* Python 3.8+\n* PyTorch 1.13\n* DGL 1.1+\n* Scipy 1.9+\n* Scikit-learn\n* Numpy\n* NetworkX\n* ogb\n* tqdm\n* easydict\n* PyYAML\n\n## Usage\n\nIf you want to quickly run an existing GSL model on a graph dataset:\n\n```python\npython main.py --dataset dataset_name --model model_name -n num_trails -g 0 --use_knn -k 5 --use_mettack --sparse --metric acc -p 0. --drop_rate 0. --add_rate 0.\n```\n\nOptional arguments:\n\n``--dataset`` : the name of graph dataset\n\n``--model`` : the name of GSL model\n\n``--ntrail -n`` : repetition count of experiments\n\n``--use_knn`` : whether to use knn graph instead of the original graph\n\n``--k`` : the number of the nearest neighbors\n\n``--drop_rate`` : the probability of randomly edge deletion\n\n``--add_rate`` : the probability of randomly edge addition\n\n``--use_mettack`` : whether to use the structure after being attacked by mettack\n\n``--ptb_rate -p`` : the perturbation rate\n\n``--metric`` : the evaluation metric\n\n``--gpu_num -g`` : the selected GPU number\n\n*Example: Train GRCN on Cora dataset, with the evaluation metric is accuracy.*\n\n```\npython main.py --dataset cora --model GRCN --metric acc\n```\n\n\n\nStep 1: Load datasets\n\n```python\nfrom GSL.data import *\n\n# load a homophilic or heterophilic graph dataset\ndata = Dataset(root='/tmp/', name='cora')\n\n# load a perturbed graph dataset\ndata = Dataset(root='/tmp/', name='cora', use_mettack=True, ptb_rate=0.05)\n\n# load a heterogeneous graph dataset\ndata = HeteroDataset(root='/tmp/', name='acm')\n\n# load a graph-level dataset\ndata = GraphDataset(root='/tmp/', name='IMDB-BINARY', model='GCN')\n```\n\nStep 2: Initialize the GSL model\n\n```python\nfrom GSL.model import *\nfrom GSL.utils import accuracy, macro_f1, micro_f1\n\nmodel_name = 'GRCN'\nmetric = 'acc'\ndevice = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n\n# the hyper-parameters are recorded in config\nconfig_path = './configs/{}_config.yaml'.format(model_name.lower())\n\n# select a evaluation metric\neval_metric = {\n  'acc': accuracy,\n  'macro-f1': macro_f1,\n  'micro-f1': micro_f1\n}[metric]\n\nmodel = GRCN(data.num_feat, data.num_class, evel_metric,\n            config_path, dataset_name, device)\n```\n\nStep 3: Train GSL model\n\n```python\nmodel.fit(data)\n```\n\n## \ud83e\udde9 Implementation Algorithms\n\nCurrently, we have implement the following GSL algorithms:\n\n* GRCN [ECML PKDD 2020], *Graph-Revised Convolutional Network*\n* ProGNN [KDD 2020], *Graph structure learning for robust graph neural networks*\n* IDGL [NeurIPS 2020], *Iterative Deep Graph Learning for Graph Neural Networks: Better and Robust Node Embeddings*\n* GEN [WWW 2021], *Graph Structure Estimation Neural Networks*\n* CoGSL [WWW 2022], *Compact Graph Structure Learning via Mutual Information Compression*\n* SLAPS [NeurIPS 2021], *SLAPS: Self-Supervision Improves Structure Learning for Graph Neural Networks*\n* SUBLIME [WWW 2022], *Towards Unsupervised Deep Graph Structure Learning*\n* STABLE [KDD 2022], *Reliable Representations Make A Stronger Defender: Unsupervised Structure Refinement for Robust GNN*\n* NodeFormer [NeurIPS 2022], *NodeFormer: A Scalable Graph Structure Learning Transformer for Node Classi\ufb01cation*\n* HES-GSL [TNNLS 2023], *Homophily-Enhanced Self-Supervision for Graph Structure Learning: Insights and Directions*\n* GTN [NeurIPS 2020], *Graph Transformer Networks*\n* HGSL [AAAI 2021], *Heterogeneous Graph Structure Learning for Graph Neural Networks*\n* HGP-SL [AAAI 2020], *Hierarchical Graph Pooling with Structure Learning*\n* VIB-GSL [AAAI 2022], *Graph Structure Learning with Variational Information Bottleneck*\n\n**Candidate algorithms**\n* NeuralSparse [ICML 2020], *Robust Graph Representation Learning via Neural Sparsification*\n* PTDNet [WSDM 2021], *Learning to Drop: Robust Graph Neural Network via Topological Denoising*\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "GSLB: Graph Structure Learning Benchmark",
    "version": "0.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/GSL-Benchmark/GSLB/issues",
        "Homepage": "https://github.com/GSL-Benchmark/GSLB"
    },
    "split_keywords": [
        "pytorch",
        "graph-neural-networks",
        "graph-structure-learning"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4b2f249c39d3f5d06858442629f17003352fc0843923558682c11bd48393f1b6",
                "md5": "28eee399cae8ec4f96857c06cc61db44",
                "sha256": "d016249a2f568a67aa5e95c55c88e3df648e9d3782220a4c88b8703c09710364"
            },
            "downloads": -1,
            "filename": "GSLB-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "28eee399cae8ec4f96857c06cc61db44",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 97364,
            "upload_time": "2023-07-12T13:10:25",
            "upload_time_iso_8601": "2023-07-12T13:10:25.279671Z",
            "url": "https://files.pythonhosted.org/packages/4b/2f/249c39d3f5d06858442629f17003352fc0843923558682c11bd48393f1b6/GSLB-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2747f7cc992971aa17a95a833fe998feb0775cf9a4a2e1061f26e21ecdf9c270",
                "md5": "262609c6f4c3a69c59ea3436670c1a27",
                "sha256": "79412061c536adf1cdf34993879c1cedbfbdfe4dc638b8f48d75f21688df3cdb"
            },
            "downloads": -1,
            "filename": "GSLB-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "262609c6f4c3a69c59ea3436670c1a27",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 79638,
            "upload_time": "2023-07-12T13:10:27",
            "upload_time_iso_8601": "2023-07-12T13:10:27.526564Z",
            "url": "https://files.pythonhosted.org/packages/27/47/f7cc992971aa17a95a833fe998feb0775cf9a4a2e1061f26e21ecdf9c270/GSLB-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-12 13:10:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "GSL-Benchmark",
    "github_project": "GSLB",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "gslb"
}
        
Elapsed time: 0.08848s