Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gat_pool #107

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
6d0bd1a
Fix bugs for feature engineers but issues of solver still exists
Mar 28, 2022
7bce26e
Fix bugs for feature engineers
Mar 28, 2022
daa31fb
add tutorial_cn
general502570 Apr 1, 2022
da7a179
add tutorial_cn/t_hetero_node_clf.rst
SwiftieH Apr 12, 2022
b696505
model tutorial
Apr 12, 2022
ec1f231
add tutorial_cn/t_homo_graph_classification_gin.rst
SwiftieH Apr 12, 2022
83fd194
fix bug in t_homo_graph_classification_gin.rst
SwiftieH Apr 12, 2022
34cf1f3
fix bug in t_homo_graph_classification_gin.rst
SwiftieH Apr 12, 2022
8fb1415
fix bug in t_homo_graph_classification_gin.rst
SwiftieH Apr 12, 2022
e0fa52a
fix bug in t_homo_graph_classification_gin.rst
SwiftieH Apr 12, 2022
9613d26
fix bug in t_homo_graph_classification_gin.rst
SwiftieH Apr 12, 2022
dca18c2
model_cn
Apr 12, 2022
67b0bb0
model_cn
Apr 12, 2022
73e6b87
model_cn
Apr 12, 2022
9184df2
add README_cn.md
Apr 13, 2022
566a34a
update readme
Apr 13, 2022
bc6bb59
Update README_cn.md
general502570 Apr 13, 2022
2f576e6
Update README_cn.md
general502570 Apr 13, 2022
19bb6f5
Update README_cn.md
general502570 Apr 13, 2022
b2a2788
ensemble cn
wondergo2017 Apr 13, 2022
e87e7b3
add fe_tutorial unit test
wondergo2017 Apr 13, 2022
c7a06ce
update fe tutorial doc
wondergo2017 Apr 13, 2022
7cce7cc
update fe_cn tutorial doc
wondergo2017 Apr 13, 2022
fd7ed45
fix nas device problem
wondergo2017 Apr 13, 2022
921edf2
fix nas nclf backend
wondergo2017 Apr 13, 2022
925c517
Update README_cn.md
general502570 Apr 13, 2022
3e78ec6
Update README_cn.md
general502570 Apr 13, 2022
dde3d3a
Revise tutorial for backend and datasets
Apr 13, 2022
9e5e996
Merge pull request #93 from THUMNLab/bugfix/fe_solver
general502570 Apr 13, 2022
17b5cdb
solver_cn and nas_bug_fixed
general502570 Apr 13, 2022
07436a2
fix quickstart
general502570 Apr 13, 2022
ac67f2c
Merge branch 'tutorial_cn_hc' of github.com:THUMNLab/AutoGL into tuto…
general502570 Apr 14, 2022
2d09296
Merge pull request #101 from THUMNLab/tutorial_cn_hc
general502570 Apr 15, 2022
7f50917
Merge pull request #99 from THUMNLab/tutorial_cn_zy
general502570 Apr 15, 2022
5b02b14
Merge pull request #102 from THUMNLab/tutorial_model
general502570 Apr 15, 2022
5e4cc64
Merge pull request #103 from THUMNLab/tutorial_zw
general502570 Apr 15, 2022
ef45b3a
Merge pull request #100 from THUMNLab/tutorial-cn_zx
general502570 Apr 15, 2022
49883a7
Merge branch 'tutorial' of github.com:THUMNLab/AutoGL into tutorial
general502570 Apr 15, 2022
a6b8408
chinese tutorial
general502570 Apr 16, 2022
da0fb53
add hetero init
general502570 Apr 16, 2022
9386d06
Update issue templates
Frozenmad Apr 17, 2022
3b69703
Merge branch 'dev' into tutorial
general502570 Apr 18, 2022
44cb078
Merge pull request #104 from THUMNLab/tutorial
general502570 Apr 18, 2022
ab25531
Update README_cn.md
general502570 Apr 18, 2022
d6aabab
Merge pull request #98 from THUMNLab/fix_nas_device
general502570 Apr 19, 2022
e65faf3
Merge pull request #97 from THUMNLab/fix#96
general502570 Apr 19, 2022
941b7c6
fix some tutorial
general502570 Apr 19, 2022
5dfdb2a
Merge branch 'dev' of github.com:THUMNLab/AutoGL into dev
general502570 Apr 19, 2022
5c0ba99
Merge branch 'dev' into main
general502570 Apr 19, 2022
487f2b2
v0.3.1
general502570 Apr 19, 2022
5901d35
gat_pool
Jun 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: bug
assignees: Frozenmad
assignees: general502570

---

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Feature request
about: Suggest an idea for this project
title: "[FEATURE]"
labels: enhancement
assignees: Frozenmad
assignees: general502570

---

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Auto Graph Learning

[Chinese Introduction](README_cn.md)

An autoML framework & toolkit for machine learning on graphs.

*Actively under development by @THUMNLab*
Expand All @@ -12,6 +14,7 @@ Feel free to open <a href="https://github.com/THUMNLab/AutoGL/issues">issues</a>

## News!

- 2022.4.19 New version v0.3.1!We have released Chinese tutorial for the first time!
- 2021.12.31 New Version! v0.3.0-pre is here!
- AutoGL now support [__Deep Graph Library (DGL)__](https://www.dgl.ai/) backend to be interface-friendly for DGL users! All the homogeneous node classification task, link prediction task, and graph classification task are currently supported under DGL backend. AutoGL is also compatible with PyG 2.0 now.
- The __heterogeneous__ node classification tasks are now supported! See [hetero tutorial](http://mn.cs.tsinghua.edu.cn/autogl/documentation/docfile/tutorial/t_hetero_node_clf.html) for more details.
Expand Down
178 changes: 178 additions & 0 deletions README_cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# 智图 (AutoGL)
[English Introduction](../..)

用于图数据的自动机器学习框架和工具包。

*由清华大学媒体与网络实验室进行开发与维护*

若有任何意见或建议,欢迎通过<a href="https://github.com/THUMNLab/AutoGL/issues">issues</a> 或邮件<a href="mailto:autogl@tsinghua.edu.cn">autogl@tsinghua.edu.cn</a>与我们联系。

<!--
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
% [![Documentation Status](http://mn.cs.tsinghua.edu.cn/autogl/documentation/?badge=latest)](http://mn.cs.tsinghua.edu.cn/autogl/documentation/?badge=latest)-->

## 最新消息

- 2022.4.19 v0.3.1版本更新!首次更新中文教程!
- 2021.12.31 v0.3.0-pre版本更新!
- 智图目前支持[__Deep Graph Library (DGL)__](https://www.dgl.ai/)作为后端,以方便DGL的用户使用。目前在DGL后端已经支持同构图的节点分类、链接预测以及图分类等任务。智图现在也可兼容PyG 2.0版本。
- 智图可以支持__异构图__节点分类任务!详情请参考[异构图教程](http://mn.cs.tsinghua.edu.cn/autogl/documentation/docfile/tutorial/t_hetero_node_clf.html)。
- 为了使智图算法更灵活,`model`模块目前支持__解耦__为两个子模块,即编码器`encoder`和解码器`decoder`。在__解耦__设计中,一个`encoder`可以被用来处理不同任务,以减少重复开发的负担,
- 我们扩展了支持的[神经架构搜索算法](http://mn.cs.tsinghua.edu.cn/autogl/documentation/docfile/tutorial/t_nas.html),例如[AutoAttend](https://proceedings.mlr.press/v139/guan21a.html),[GASSO](https://proceedings.neurips.cc/paper/2021/hash/8c9f32e03aeb2e3000825c8c875c4edd-Abstract.html), [硬件感知算法](http://mn.cs.tsinghua.edu.cn/autogl/documentation/docfile/documentation/nas.html#autogl.module.nas.estimator.OneShotEstimator_HardwareAware)等。
- 2021.07.11 智图更新v0.2.0-pre版本! 在新版本中,智图支持[神经架构搜索(NAS)](http://mn.cs.tsinghua.edu.cn/autogl/documentation/docfile/tutorial/t_nas.html),可以对给定的数据集和架构定制化神经网络架构。智图也支持了[采样](http://mn.cs.tsinghua.edu.cn/autogl/documentation/docfile/tutorial/t_trainer.html#node-classification-with-sampling)功能以处理大规模图数据集,包括节点采样、层采样和子图采样。链接预测任务也已经支持。详情请参考我们的[教程](http://mn.cs.tsinghua.edu.cn/autogl/documentation/index.html).
- 2021.04.16 我们关于图自动机器学习的综述文章已经被IJCAI 2021接受! 详情见[这里](http://arxiv.org/abs/2103.00742)。
- 2021.04.10 我们的论文[__AutoGL: A Library for Automated Graph Learning__](https://arxiv.org/abs/2104.04987)已经被 _ICLR 2021 Workshop on Geometrical and Topological Representation Learning_ 接受!

## 介绍

智图的设计目标是可以简单、快速地对图数据集和任务进行自动机器学习,可供研究者和开发者使用。更多详细信息,可以参阅我们的文档。

下图是智图的整体框架。

<img src="./resources/workflow.svg">

智图通过 `datasets` 类以支持图数据集,其基于 PyTorch Geometric 和 Deep Graph Library 的数据集,并添加了一些函数以支持自动机器学习框架。

智图通过 `AutoGL solvers` 以处理不同的图机器学习任务,利用五个主要模块自动解决给定的任务,即自动特征工程 `auto feature engineer`,神经架构搜索 `neural architecture search`,自动模型 `auto model`,超参数优化 `hyperparameter optimization`,和自动模型集成 `auto ensemble`。

目前,智图支持以下算法:

<table>
<tbody>
<tr valign="top">
<td>特征工程</td>
<td>图模型</td>
<td>神经架构搜索</td>
<td>超参数优化</td>
<td>模型集成</td>
</tr>
<tr valign="top">
<td><b>生成器</b><br>Graphlets <br> EigenGNN <br> <a href="http://mn.cs.tsinghua.edu.cn/autogl/documentation/docfile/tutorial/t_fe.html">更多 ...</a><br><br><b>选择器</b><br> SeFilterConstant<br> gbdt <br> <br><b>全图特征</b><br> Netlsd<br> NxAverageClustering<br> <a href="http://mn.cs.tsinghua.edu.cn/autogl/documentation/docfile/tutorial/t_fe.html">更多 ...</a></td>
<td><b>同构图编码器</b><br> GCNEncoder <br> GATEncoder <br> SAGEEncoder <br> GINEncoder <br> <br><b>解码器</b><br>LogSoftmaxDecoder <br> DotProductDecoder <br> SumPoolMLPDecoder <br> JKSumPoolDecoder </td>
<td>
<b>搜索算法</b><br>
Random<br>
RL<br>
Evolution<br>
GASSO<br>
<a href='http://mn.cs.tsinghua.edu.cn/autogl/documentation/docfile/documentation/nas.html'>更多 ...</a><br><br>
<b>搜索空间</b><br>
SinglePath<br>
GraphNas<br>
AutoAttend<br>
<a href='http://mn.cs.tsinghua.edu.cn/autogl/documentation/docfile/documentation/nas.html'>更多 ...</a><br><br>
<b>模型评估</b><br>
Oneshot<br>
Scratch<br>
</td>
<td> Grid <br> Random <br> Anneal <br> Bayes <br> CAMES <br> MOCAMES <br> Quasi random <br> TPE <br> AutoNE </td>
<td> Voting <br> Stacking </td>
</tr>
</tbody>
</table>

此工具包还可作为一个框架供用户实现和测试自己的自动机器学习或图机器学习模型。

## 安装

### 依赖

在安装智图之前,请首先安装以下依赖项。

1. Python >= 3.6.0

2. PyTorch (>=1.6.0)

详细信息请参考<https://pytorch.org/>。

3. 图机器学习工具包

智图需要 PyTorch Geometric(PyG)或 Deep Graph Library(DGL)作为后端。若两者均安装,可在运行时选择任一后端,参考[这里](http://mn.cs.tsinghua.edu.cn/autogl/documentation/docfile/tutorial/t_backend.html)。

3.1 PyTorch Geometric (>=1.7.0)

详细信息请参考<https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html/>。

3.2 Deep Graph Library (>=0.7.0)

详细信息请参考<https://dgl.ai/>。


### 安装

#### 通过pip进行安装

运行以下命令以通过`pip`安装智图。

```
pip install autogl
```

#### 从源代码安装

运行以下命令以从源安装智图。

```
git clone https://github.com/THUMNLab/AutoGL.git
cd AutoGL
python setup.py install
```

#### 开发者安装

如果您想以开发者方式安装智图,请运行以下命令以创建软链接,然后即可修改本地程序后而无需重复安装。
```
pip install -e .
```

## 文档

您可参考<a href="http://mn.cs.tsinghua.edu.cn/autogl/documentation/">文档页面</a> 以参阅我们的详细文档。

文档也可以进行本地编译。首先,请安装 sphinx 和 sphinx-rtd-theme:
```
pip install -U Sphinx
pip install sphinx-rtd-theme
```

然后,通过以下方式创建 html 文档:
```
cd docs
make clean && make html
```
文档将在如下路径自动生成:`docs/_build/html`

## 引用

如果您使用了智图代码,请按如下方式引用我们的[论文](https://openreview.net/forum?id=0yHwpLeInDn):
```
@inproceedings{guan2021autogl,
title={Auto{GL}: A Library for Automated Graph Learning},
author={Chaoyu Guan and Ziwei Zhang and Haoyang Li and Heng Chang and Zeyang Zhang and Yijian Qin and Jiyan Jiang and Xin Wang and Wenwu Zhu},
booktitle={ICLR 2021 Workshop on Geometrical and Topological Representation Learning},
year={2021},
url={https://openreview.net/forum?id=0yHwpLeInDn}
}
```

或许您也会发现我们的[综述](http://arxiv.org/abs/2103.00742)有帮助:
```
@article{zhang2021automated,
title={Automated Machine Learning on Graphs: A Survey},
author={Zhang, Ziwei and Wang, Xin and Zhu, Wenwu},
booktitle = {Proceedings of the Thirtieth International Joint Conference on Artificial Intelligence, {IJCAI-21}},
year={2021},
note={Survey track}
}
```

## 版权相关
从v0.2版本开始,智图的所有代码采用[Apache license](LICENSE)。

## 用户交流微信群
![weixin](https://user-images.githubusercontent.com/17705534/163801846-2aa1bdf8-919e-4636-b7d9-e5346f352c15.jpg)





2 changes: 1 addition & 1 deletion autogl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
train,
)

__version__ = "0.3.0-pre"
__version__ = "0.3.1"
8 changes: 7 additions & 1 deletion autogl/module/feature/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
from ._selectors import (
FilterConstant, GBDTFeatureSelector
)
from ._auto_feature import (
IdentityFeature, OnlyConstFeature, AutoFeatureEngineer
)

__all__ = [
"BaseFeatureEngineer",
Expand Down Expand Up @@ -61,5 +64,8 @@
"NXGlobalEfficiency",
"NXIsEulerian",
"FilterConstant",
"GBDTFeatureSelector"
"GBDTFeatureSelector",
"IdentityFeature",
"OnlyConstFeature",
"AutoFeatureEngineer"
]
4 changes: 2 additions & 2 deletions autogl/module/feature/_auto_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def __init__(
verbosity: int = 0,
*args, **kwargs
):
super(AutoFeatureEngineer, self).__init__(multi_graph=False)
super(AutoFeatureEngineer, self).__init__()
self._ops = [op_sum, op_mean, op_max, op_min]
self._sim = cosine_similarity
self._fixlen = fix_length
Expand Down Expand Up @@ -208,7 +208,7 @@ def _fit(self, homogeneous_static_graph: autogl.data.graph.GeneralStaticGraph):
for u, v in homogeneous_static_graph.edges.connections.t().numpy():
neighbours[u].append(v)
self.__neighbours: _typing.Sequence[np.ndarray] = tuple(
[np.ndarray(v) for v in neighbours]
[np.array(v) for v in neighbours]
)

x: np.ndarray = _original_features.numpy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ def transform(self, dataset, inplace: bool = True):
return dataset

def fit_transform(self, dataset, inplace: bool = True):
return self.fit_transform(dataset, inplace)
for fe in self.fe_components:
dataset = fe.fit(dataset)
for fe in self.fe_components:
dataset = fe.transform(dataset)
return dataset

def __init__(self, feature_engineers: _typing.Iterable[_AbstractBaseFeatureEngineer]):
self.__fe_components: _typing.List[_AbstractBaseFeatureEngineer] = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def fit(self, dataset):
with torch.no_grad():
for i, data in enumerate(dataset):
dataset[i] = self.__postprocess(
self._postprocess(self._transform(self._fit(self._preprocess(self.__preprocess(data)))))
self._postprocess(self._fit(self._preprocess(self.__preprocess(data))))
)
return dataset

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def fit(self, dataset):
with torch.no_grad():
for i, data in enumerate(dataset):
dataset[i] = self.__postprocess(
self._postprocess(self._transform(self._fit(self._preprocess(self.__preprocess(data)))))
self._postprocess(self._fit(self._preprocess(self.__preprocess(data))))
)
return dataset

Expand Down
8 changes: 2 additions & 6 deletions autogl/module/feature/_selectors/_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@ def __transform_homogeneous_static_graph(
) -> GeneralStaticGraph:
if (
'x' in static_graph.nodes.data and
self._selection not in (Ellipsis, None) and
isinstance(self._selection, torch.Tensor) and
torch.is_tensor(self._selection) and self._selection.dim() == 1
isinstance(self._selection, (torch.Tensor, np.ndarray))
):
static_graph.nodes.data['x'] = static_graph.nodes.data['x'][:, self._selection]
if (
'feat' in static_graph.nodes.data and
self._selection not in (Ellipsis, None) and
isinstance(self._selection, torch.Tensor) and
torch.is_tensor(self._selection) and self._selection.dim() == 1
isinstance(self._selection, (torch.Tensor, np.ndarray))
):
static_graph.nodes.data['feat'] = static_graph.nodes.data['feat'][:, self._selection]
return static_graph
Expand Down
3 changes: 2 additions & 1 deletion autogl/module/feature/_selectors/_gbdt.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def _gbdt_generator(
)

num_classes: int = torch.max(data.y).item() + 1
parameters["num_class"] = num_classes
__optimizer_parameters = {
"num_boost_round": 100,
"early_stopping_rounds": 5,
Expand Down Expand Up @@ -78,7 +79,7 @@ def _gbdt_generator(
train_x = pd.DataFrame(x, columns=feature_index, index=None)
dtrain = lightgbm.Dataset(train_x, label=label)
clf = lightgbm.train(
train_set=dtrain, params=params,
train_set=dtrain, params=parameters,
**__optimizer_parameters
)

Expand Down
Empty file.
2 changes: 2 additions & 0 deletions autogl/module/model/pyg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .gcn import AutoGCN
from .gat import AutoGAT
from .gin import AutoGIN
from .gin_gat_glf import AutoGATPooling

__all__ = [
"ModelUniversalRegistry",
Expand All @@ -19,4 +20,5 @@
"AutoGCN",
"AutoGAT",
"AutoGIN",
"AutoGATPooling"
]
Loading