Skip to content

Commit

Permalink
add source free models
Browse files Browse the repository at this point in the history
  • Loading branch information
cszhangzhen committed Dec 7, 2024
1 parent 9479f50 commit 801d571
Show file tree
Hide file tree
Showing 16 changed files with 1,871 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.pyc
test.py
testg.py
testn.py
data/*
!data/README.md
bench/
Expand Down
42 changes: 24 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ logits, labels = model.predict(target_data)
* **Seamlessly integrated data processing with PyG, ensuring full compatibility with PyG data structures.**

## :loudspeaker: What's New?
We support graph-level domain adaptation task.
**[12/2024]**. We now support source-free setting of graph domain adaptation.
- 3 recent models including `GTrans`, `SOGA` and `GraphCTA` are supported.

**[08/2024]**. We support graph-level domain adaptation task.
- 7 models including `A2GNN`, `AdaGCN`, `CWGCN`, `DANE`, `GRADE`, `SAGDA`, `UDAGCN` are supported.
- Various TUDatasets are supported including `FRANKENSTEIN`, `Mutagenicity` and `PROTEINS`.
- To perform a graph-level domain adaptation task, only one parameter is added to the model as follows:
```
model = A2GNN(in_dim=num_features, hid_dim=args.nhid, num_classes=num_classes, mode='graph', device=args.device)
```


## Installation
Note: PyGDA depends on [PyTorch](https://pytorch.org/), [PyG](https://pytorch-geometric.readthedocs.io/en/latest/), [PyTorch Sparse](https://github.com/rusty1s/pytorch_sparse) and [Pytorch Scatter](https://github.com/rusty1s/pytorch_scatter). PyGDA does not automatically install these libraries for you. Please install them separately in order to run PyGDA successfully.

Expand Down Expand Up @@ -107,22 +109,26 @@ In addition to the easy application of existing GDA models, PyGDA makes it simpl

| **ID** | **Paper** | **Method** | **Venue** |
|--------|---------|:----------:|:--------------:|
| 1 | [DANE: Domain Adaptive Network Embedding](https://www.ijcai.org/proceedings/2019/606) | DANE | IJCAI 2019 |
| 2 | [Adversarial Deep Network Embedding for Cross-network Node Classification](https://arxiv.org/abs/2002.07366) | ACDNE | AAAI 2020 |
| 3 | [Unsupervised Domain Adaptive Graph Convolutional Networks](https://dl.acm.org/doi/10.1145/3366423.3380219) | UDAGCN | WWW 2020 |
| 4 | [Adversarial Separation Network for Cross-Network Node Classification](https://dl.acm.org/doi/abs/10.1145/3459637.3482228) | ASN | CIKM 2021 |
| 5 | [Graph Transfer Learning via Adversarial Domain Adaptation with Graph Convolution](https://arxiv.org/abs/1909.01541) | AdaGCN | TKDE 2022 |
| 6 | [Non-IID Transfer Learning on Graphs](https://ojs.aaai.org/index.php/AAAI/article/view/26231) | GRADE | AAAI 2023 |
| 7 | [Graph Domain Adaptation via Theory-Grounded Spectral Regularization](https://openreview.net/forum?id=OysfLgrk8mk) | SpecReg | ICLR 2023 |
| 8 | [Structural Re-weighting Improves Graph Domain Adaptation](https://arxiv.org/abs/2306.03221) | StruRW | ICML 2023 |
| 9 | [Improving Graph Domain Adaptation with Network Hierarchy](https://dl.acm.org/doi/10.1145/3583780.3614928) | JHGDA | CIKM 2023 |
| 10 | [Bridged-GNN: Knowledge Bridge Learning for Effective Knowledge Transfer](https://dl.acm.org/doi/10.1145/3583780.3614796) | KBL | CIKM 2023 |
| 11 | [Domain-adaptive Message Passing Graph Neural Network](https://www.sciencedirect.com/science/article/abs/pii/S0893608023002253) | DMGNN | NN 2023 |
| 12 | [Correntropy-Induced Wasserstein GCN: Learning Graph Embedding via Domain Adaptation](https://ieeexplore.ieee.org/document/10179964) | CWGCN | TIP 2023 |
| 13 | [SA-GDA: Spectral Augmentation for Graph Domain Adaptation](https://dl.acm.org/doi/10.1145/3581783.3612264) | SAGDA | MM 2023 |
| 14 | [Graph Domain Adaptation: A Generative View](https://dl.acm.org/doi/10.1145/3631712) | DGDA | TKDD 2024 |
| 15 | [Rethinking Propagation for Unsupervised Graph Domain Adaptation](https://arxiv.org/abs/2402.05660) | A2GNN | AAAI 2024 |
| 16 | [Pairwise Alignment Improves Graph Domain Adaptation](https://arxiv.org/abs/2403.01092) | PairAlign | ICML 2024 |
| 1 | [Semi-Supervised Classification with Graph Convolutional Networks](https://arxiv.org/abs/1609.02907) | Vanilla GCN | ICLR 2017 |
| 2 | [DANE: Domain Adaptive Network Embedding](https://www.ijcai.org/proceedings/2019/606) | DANE | IJCAI 2019 |
| 3 | [Adversarial Deep Network Embedding for Cross-network Node Classification](https://arxiv.org/abs/2002.07366) | ACDNE | AAAI 2020 |
| 4 | [Unsupervised Domain Adaptive Graph Convolutional Networks](https://dl.acm.org/doi/10.1145/3366423.3380219) | UDAGCN | WWW 2020 |
| 5 | [Adversarial Separation Network for Cross-Network Node Classification](https://dl.acm.org/doi/abs/10.1145/3459637.3482228) | ASN | CIKM 2021 |
| 6 | [Graph Transfer Learning via Adversarial Domain Adaptation with Graph Convolution](https://arxiv.org/abs/1909.01541) | AdaGCN | TKDE 2022 |
| 7 | [Non-IID Transfer Learning on Graphs](https://ojs.aaai.org/index.php/AAAI/article/view/26231) | GRADE | AAAI 2023 |
| 8 | [Graph Domain Adaptation via Theory-Grounded Spectral Regularization](https://openreview.net/forum?id=OysfLgrk8mk) | SpecReg | ICLR 2023 |
| 9 | [Structural Re-weighting Improves Graph Domain Adaptation](https://arxiv.org/abs/2306.03221) | StruRW | ICML 2023 |
| 10 | [Improving Graph Domain Adaptation with Network Hierarchy](https://dl.acm.org/doi/10.1145/3583780.3614928) | JHGDA | CIKM 2023 |
| 11 | [Bridged-GNN: Knowledge Bridge Learning for Effective Knowledge Transfer](https://dl.acm.org/doi/10.1145/3583780.3614796) | KBL | CIKM 2023 |
| 12 | [Domain-adaptive Message Passing Graph Neural Network](https://www.sciencedirect.com/science/article/abs/pii/S0893608023002253) | DMGNN | NN 2023 |
| 13 | [Correntropy-Induced Wasserstein GCN: Learning Graph Embedding via Domain Adaptation](https://ieeexplore.ieee.org/document/10179964) | CWGCN | TIP 2023 |
| 14 | [SA-GDA: Spectral Augmentation for Graph Domain Adaptation](https://dl.acm.org/doi/10.1145/3581783.3612264) | SAGDA | MM 2023 |
| 15 | [Graph Domain Adaptation: A Generative View](https://dl.acm.org/doi/10.1145/3631712) | DGDA | TKDD 2024 |
| 16 | [Rethinking Propagation for Unsupervised Graph Domain Adaptation](https://arxiv.org/abs/2402.05660) | A2GNN | AAAI 2024 |
| 17 | [Pairwise Alignment Improves Graph Domain Adaptation](https://arxiv.org/abs/2403.01092) | PairAlign | ICML 2024 |
| 18 | [Empowering Graph Representation Learning with Test-Time Graph Transformation](https://arxiv.org/abs/2210.03561) | GTrans | ICLR 2023 |
| 19 | [Source Free Unsupervised Graph Domain Adaptation](https://arxiv.org/abs/2112.00955) | SOGA | WSDM 2024 |
| 20 | [Collaborate to Adapt: Source-Free Graph Domain Adaptation via Bi-directional Adaptation](https://dl.acm.org/doi/10.1145/3589334.3645507) | GraphCTA | WWW 2024 |


## Cite
Expand Down
7 changes: 7 additions & 0 deletions docs/GTrans.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
::: pygda.models.gtrans
options:
docstring_style: numpy
show_source: false
merge_init_into_class: true
ignore_init_summary: true
heading_level: 6
7 changes: 7 additions & 0 deletions docs/GraphCTA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
::: pygda.models.graphcta
options:
docstring_style: numpy
show_source: false
merge_init_into_class: true
ignore_init_summary: true
heading_level: 6
7 changes: 7 additions & 0 deletions docs/SOGA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
::: pygda.models.soga
options:
docstring_style: numpy
show_source: false
merge_init_into_class: true
ignore_init_summary: true
heading_level: 6
60 changes: 57 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

![](pygda_logo.png)
-----
[![PyPI - Version](https://img.shields.io/pypi/v/pygda?style=flat)](https://pypi.org/project/pygda/)
[![Documentation Status](https://readthedocs.org/projects/pygda/badge/?version=stable)](https://pygda.readthedocs.io/en/stable/?badge=stable)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/pygda-team/pygda/issues)

PyGDA is a **Python library** for **Graph Domain Adaptation** built upon [PyTorch](https://pytorch.org/) and [PyG](https://pytorch-geometric.readthedocs.io/en/latest/) to easily train graph domain adaptation models in a [sklearn](https://scikit-learn.org/stable/) style. PyGDA includes **15+** graph domain adaptation models. See examples with PyGDA below!

Expand All @@ -19,12 +23,23 @@ model.fit(source_data, target_data)
logits, labels = model.predict(target_data)
```
**PyGDA is featured for:**

* **Consistent APIs and comprehensive documentation.**
* **Cover 15+ graph domain adaptation models.**
* **Scalable architecture that efficiently handles large graph datasets through mini-batching and sampling techniques.**
* **Seamlessly integrated data processing with PyG, ensuring full compatibility with PyG data structures.**

## :loudspeaker: What's New?
**[12/2024]**. We now support source-free setting of graph domain adaptation.
- 3 recent models including `GTrans`, `SOGA` and `GraphCTA` are supported.

**[08/2024]**. We support graph-level domain adaptation task.
- 7 models including `A2GNN`, `AdaGCN`, `CWGCN`, `DANE`, `GRADE`, `SAGDA`, `UDAGCN` are supported.
- Various TUDatasets are supported including `FRANKENSTEIN`, `Mutagenicity` and `PROTEINS`.
- To perform a graph-level domain adaptation task, only one parameter is added to the model as follows:
```
model = A2GNN(in_dim=num_features, hid_dim=args.nhid, num_classes=num_classes, mode='graph', device=args.device)
```

## Installation
Note: PyGDA depends on [PyTorch](https://pytorch.org/), [PyG](https://pytorch-geometric.readthedocs.io/en/latest/), [PyTorch Sparse](https://github.com/rusty1s/pytorch_sparse) and [Pytorch Scatter](https://github.com/rusty1s/pytorch_scatter). PyGDA does not automatically install these libraries for you. Please install them separately in order to run PyGDA successfully.

Expand All @@ -46,7 +61,7 @@ Note: PyGDA depends on [PyTorch](https://pytorch.org/), [PyG](https://pytorch-ge
pip install pygda
```

or
or

**Installation for local development:**
```
Expand Down Expand Up @@ -89,6 +104,45 @@ ma_f1 = eval_macro_f1(labels, preds)

## Create your own GDA model
In addition to the easy application of existing GDA models, PyGDA makes it simple to implement custom models.

* the customed model should inherit ``BaseGDA`` class.
* implement your ``fit()``, ``forward_model()``, and ``predict()`` functions.

## Reference

| **ID** | **Paper** | **Method** | **Venue** |
|--------|---------|:----------:|:--------------:|
| 1 | [Semi-Supervised Classification with Graph Convolutional Networks](https://arxiv.org/abs/1609.02907) | Vanilla GCN | ICLR 2017 |
| 2 | [DANE: Domain Adaptive Network Embedding](https://www.ijcai.org/proceedings/2019/606) | DANE | IJCAI 2019 |
| 3 | [Adversarial Deep Network Embedding for Cross-network Node Classification](https://arxiv.org/abs/2002.07366) | ACDNE | AAAI 2020 |
| 4 | [Unsupervised Domain Adaptive Graph Convolutional Networks](https://dl.acm.org/doi/10.1145/3366423.3380219) | UDAGCN | WWW 2020 |
| 5 | [Adversarial Separation Network for Cross-Network Node Classification](https://dl.acm.org/doi/abs/10.1145/3459637.3482228) | ASN | CIKM 2021 |
| 6 | [Graph Transfer Learning via Adversarial Domain Adaptation with Graph Convolution](https://arxiv.org/abs/1909.01541) | AdaGCN | TKDE 2022 |
| 7 | [Non-IID Transfer Learning on Graphs](https://ojs.aaai.org/index.php/AAAI/article/view/26231) | GRADE | AAAI 2023 |
| 8 | [Graph Domain Adaptation via Theory-Grounded Spectral Regularization](https://openreview.net/forum?id=OysfLgrk8mk) | SpecReg | ICLR 2023 |
| 9 | [Structural Re-weighting Improves Graph Domain Adaptation](https://arxiv.org/abs/2306.03221) | StruRW | ICML 2023 |
| 10 | [Improving Graph Domain Adaptation with Network Hierarchy](https://dl.acm.org/doi/10.1145/3583780.3614928) | JHGDA | CIKM 2023 |
| 11 | [Bridged-GNN: Knowledge Bridge Learning for Effective Knowledge Transfer](https://dl.acm.org/doi/10.1145/3583780.3614796) | KBL | CIKM 2023 |
| 12 | [Domain-adaptive Message Passing Graph Neural Network](https://www.sciencedirect.com/science/article/abs/pii/S0893608023002253) | DMGNN | NN 2023 |
| 13 | [Correntropy-Induced Wasserstein GCN: Learning Graph Embedding via Domain Adaptation](https://ieeexplore.ieee.org/document/10179964) | CWGCN | TIP 2023 |
| 14 | [SA-GDA: Spectral Augmentation for Graph Domain Adaptation](https://dl.acm.org/doi/10.1145/3581783.3612264) | SAGDA | MM 2023 |
| 15 | [Graph Domain Adaptation: A Generative View](https://dl.acm.org/doi/10.1145/3631712) | DGDA | TKDD 2024 |
| 16 | [Rethinking Propagation for Unsupervised Graph Domain Adaptation](https://arxiv.org/abs/2402.05660) | A2GNN | AAAI 2024 |
| 17 | [Pairwise Alignment Improves Graph Domain Adaptation](https://arxiv.org/abs/2403.01092) | PairAlign | ICML 2024 |
| 18 | [Empowering Graph Representation Learning with Test-Time Graph Transformation](https://arxiv.org/abs/2210.03561) | GTrans | ICLR 2023 |
| 19 | [Source Free Unsupervised Graph Domain Adaptation](https://arxiv.org/abs/2112.00955) | SOGA | WSDM 2024 |
| 20 | [Collaborate to Adapt: Source-Free Graph Domain Adaptation via Bi-directional Adaptation](https://dl.acm.org/doi/10.1145/3589334.3645507) | GraphCTA | WWW 2024 |


## Cite

If you compare with, build on, or use aspects of PyGDA, please consider citing "[Revisiting, Benchmarking and Understanding Unsupervised Graph Domain Adaptation](https://arxiv.org/abs/2407.11052)":

```
@inproceedings{liu2024revisiting,
title={Revisiting, Benchmarking and Understanding Unsupervised Graph Domain Adaptation},
author={Meihan Liu and Zhen Zhang and Jiachen Tang and Jiajun Bu and Bingsheng He and Sheng Zhou},
booktitle={The Thirty-eight Conference on Neural Information Processing Systems Datasets and Benchmarks Track},
year={2024},
url={https://openreview.net/forum?id=ZsyFwzuDzD}
}
```
8 changes: 7 additions & 1 deletion pygda/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from .cwgcn import CWGCN
from .dmgnn import DMGNN
from .pa import PairAlign
from .soga import SOGA
from .gtrans import GTrans
from .graphcta import GraphCTA


__all__ = [
Expand All @@ -36,5 +39,8 @@
"SAGDA",
"CWGCN",
"DMGNN",
"PairAlign"
"PairAlign",
"SOGA",
"GTrans",
"GraphCTA"
]
Loading

0 comments on commit 801d571

Please sign in to comment.