余利区

 找回密码
 立即注册
查看: 102|回复: 9

图卷积神经网络 with Keras

[复制链接]

1

主题

1

帖子

3

积分

新手上路

Rank: 1

积分
3
发表于 2022-12-6 14:17:53 | 显示全部楼层 |阅读模式
使用Keras实现的图卷积神经网络 A Simplified Graph Convolutional Network with Keras

Github Link(qiu star):
**Clike Here for** [English Version](#English_Version)
使用Keras实现,用于半监督节点分类的图卷积神经网络。相比如作者提供的源代码,重写了部分主函数和功能块,使其比源代码更加简洁同时算法的性能与原论文中描述结果保持一致。感谢大佬的开源代码:
1. TensorFlow : <tkipf/gcn>
2. Keras : <tkipf/keras-gcn>
如果您想了解更多关于图卷积神经网络 (GCN) 的原理,请参考作者的原论文,博客以及知乎上的回答:
1. Thomas N. Kipf, Max Welling, [Semi-Supervised Classification with Graph Convolutional Networks](Semi-Supervised Classification with Graph Convolutional Networks) (ICLR 2017)

2. Thomas Kipf, [Graph Convolutional Networks](How powerful are Graph Convolutional Networks?) (2016)

3. [知乎:如何理解 Graph Convolutional Network(GCN)?](如何理解 Graph Convolutional Network(GCN)?)
依赖库和安装

在运行此Python代码时,需要安装文件'requirements.txt'中的Python库。安装很简单,只需下面一条命令即可:
   $  pip install -r requirements.txt用法和性能

默认使用的数据集是Cora网络,关于数据集的详细介绍能在文件夹data中找到。在该项目的目录中,执行下面的一条命令就行能运行:
    $ python train.py
该代码的性能与原论文中结果保持一致,代码最后输出如下:
```
2708/2708 [==============================] - 0s 7us/step
Test Done.
Test loss: 1.0794732570648193
Test accuracy: 0.8139998912811279

[Done] exited with code=0 in 25.405 seconds
```
推荐使用tensorflow-GPU的版本,我的GPU是NVIDIA GTX 1060。如果你使用更好的GPU(比如 TITAN RTX ),能跑的更快!:heart_eyes:

# English_Version
## A Simplified Graph Convolutional Network with Keras
Keras-based implementation of graph convolutional networks **(GCN)** for semi-supervised classification. Rewrite a part of main function and some utils which is more simple compared the author's implementation. Thanks for his open source code at the following links :

1. TensorFlow : <tkipf/gcn>
2. Keras : <tkipf/keras-gcn>

For a more detail explanation of the GCN, have a look at the relevent paper and blog post by the orignal author :

1. Thomas N. Kipf, Max Welling, [Semi-Supervised Classification with Graph Convolutional Networks](Semi-Supervised Classification with Graph Convolutional Networks) (ICLR 2017)

2. Thomas Kipf, [Graph Convolutional Networks](How powerful are Graph Convolutional Networks?) (2016)

## Dependencies and Installation

Before to execute this algorithm writed in Python, it is necessary to install these required packages shown in the file named ' requirements.txt '. You can also install all the required packages by just using one command :

    $ pip install -r requirements.txt
## Usage and Performance

The default dataset is Cora Network and the detail description can be found in the file data. Just execute the following command from the project home directory :

    $ python train.py
The performance consists with the benchmark described in the paper. The partial of output are following :

```
2708/2708 [==============================] - 0s 7us/step
Test Done.
Test loss: 1.0794732570648193
Test accuracy: 0.8139998912811279

[Done] exited with code=0 in 25.405 seconds
```

Recommand to use the tensorflow-GPU as backend and My GPU is NVIDIA GTX 1060. You can run it faster with the better GPU.

## Cite

Please cite the paper if you use this code in your own work:

```
@inproceedings{kipf2017semi,
  title={Semi-Supervised Classification with Graph Convolutional Networks},
  author={Kipf, Thomas N. and Welling, Max},
  booktitle={International Conference on Learning Representations (ICLR)},
  year={2017}
}
```
回复

使用道具 举报

3

主题

7

帖子

12

积分

新手上路

Rank: 1

积分
12
发表于 2022-12-6 14:18:02 | 显示全部楼层
谢谢你的关注!
目前GCN在半监督节点分类任务上输入的是:图结构,所有节点的属性,部分节点的标签;输出的是:剩余节点的标签。
也可以进行监督任务,参考GraphSage算法中的推导式图学习任务。
回复

使用道具 举报

4

主题

10

帖子

18

积分

新手上路

Rank: 1

积分
18
发表于 2022-12-6 14:18:28 | 显示全部楼层
请问数据集来自于哪里
回复

使用道具 举报

3

主题

6

帖子

12

积分

新手上路

Rank: 1

积分
12
发表于 2022-12-6 14:19:24 | 显示全部楼层
文中提到的论文中的实验部分有介绍的
回复

使用道具 举报

0

主题

6

帖子

0

积分

新手上路

Rank: 1

积分
0
发表于 2022-12-6 14:20:17 | 显示全部楼层
运行了一下你的keras代码,accuracy只有30%左右,与原作者的不一样啊
回复

使用道具 举报

1

主题

2

帖子

3

积分

新手上路

Rank: 1

积分
3
发表于 2022-12-6 14:20:49 | 显示全部楼层
您好 我设置了early stop 你把代码中的参数patience调大些,例如30
回复

使用道具 举报

0

主题

4

帖子

5

积分

新手上路

Rank: 1

积分
5
发表于 2022-12-6 14:21:01 | 显示全部楼层
非常感谢,已经测试成功。
回复

使用道具 举报

2

主题

8

帖子

11

积分

新手上路

Rank: 1

积分
11
发表于 2022-12-6 14:21:55 | 显示全部楼层
您好,非常感谢您的代码哈~!能否再请问一个问题,半监督节点分类的GCN是使用graph的部分有标签的节点进行训练,从而预测部分无标签的节点类别是吗?那么GCN是否能够进行有监督的分类任务?即对所有带标签的节点进行训练,之后实现对无标签的所有节点进行分类
[疑惑]
回复

使用道具 举报

2

主题

4

帖子

7

积分

新手上路

Rank: 1

积分
7
发表于 2022-12-6 14:22:23 | 显示全部楼层
大侠你好,请问根据这个程序是否可以实现预测呢,比如天气预测
回复

使用道具 举报

1

主题

4

帖子

4

积分

新手上路

Rank: 1

积分
4
发表于 2022-12-6 14:22:50 | 显示全部楼层
您好,要看你数据的类型,例如是社交网络数据,具有天然的图结构,就很容易的使用GCN进行好友预测等等任务
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

云顶设计嘉兴有限公司模板设计.

免责声明:本站上数据均为演示站数据,如购买模板可以上DISCUZ应用中心购买,欢迎惠顾.

云顶官方站点:云顶设计 模板原创设计:云顶模板   Powered by Discuz! X3.4© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表