Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
G

gcn

> 编程语言
Open source

Implementation of Graph Convolutional Networks in TensorFlow

7.4K stars0 likes1 views
WebsiteGitHub

About

Implementation of Graph Convolutional Networks in TensorFlow

Graph Convolutional Networks

This is a TensorFlow implementation of Graph Convolutional Networks for the task of (semi-supervised) classification of nodes in a graph, as described in our paper:

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

For a high-level explanation, have a look at our blog post:

Thomas Kipf, Graph Convolutional Networks (2016)

Installation

bash
python setup.py install

Requirements

  • tensorflow (>0.12)
  • networkx

Run the demo

bash
cd gcn
python train.py

Data

In order to use your own data, you have to provide

  • an N by N adjacency matrix (N is the number of nodes),
  • an N by D feature matrix (D is the number of features per node), and
  • an N by E binary label matrix (E is the number of classes).

Have a look at the load_data() function in utils.py for an example.

In this example, we load citation network data (Cora, Citeseer or Pubmed). The original datasets can be found here: http://www.cs.umd.edu/~sen/lbc-proj/LBC.html. In our version (see data folder) we use dataset splits provided by https://github.com/kimiyoung/planetoid (Zhilin Yang, William W. Cohen, Ruslan Salakhutdinov, Revisiting Semi-Supervised Learning with Graph Embeddings, ICML 2016).

You can specify a dataset as follows:

bash
python train.py --dataset citeseer

(or by editing train.py)

Models

You can choose between the following models:

  • gcn: Graph convolutional network (Thomas N. Kipf, Max Welling, Semi-Supervised Classification with Graph Convolutional Networks, 2016)
  • gcn_cheby: Chebyshev polynomial version of graph convolutional network as described in (Michaël Defferrard, Xavier Bresson, Pierre Vandergheynst, Convolutional Neural Networks on Graphs with Fast Localized Spectral Filtering, NIPS 2016)
  • dense: Basic multi-layer perceptron that supports sparse inputs

Graph classification

Our framework also supports batch-wise classification of multiple graph instances (of potentially different size) with an adjacency matrix each. It is best to concatenate respective feature matrices and build a (sparse) block-diagonal matrix where each block corresponds to the adjacency matrix of one graph instance. For pooling (in case of graph-level outputs as opposed to node-level outputs) it is best to specify a simple pooling matrix that collects features from their respective graph instances, as illustrated below:

Cite

Please cite our 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}
}

Issues· 124 open

View all issuesOpen on GitHub
  • #222

    Can you write a API reference?

    Updated May 5, 2025
  • #223

    Problems executing preprocess_features(features) in train.py

    Updated Mar 13, 2025
  • #4

    Graph Classification & Batchwise Training

    Updated Feb 13, 2024
  • #173

    C/C++ implementation of GCN

    Updated Nov 2, 2023
  • #221

    implemention of cij

    Updated Aug 10, 2023
  • #211

    Installation: Version of Tensor flow

    Updated May 16, 2023
  • #91

    Is it possible to apply your GCN on directed graphs ?

    Updated May 15, 2023
  • #220

    > Why not keep directed citation edges?

    Updated May 15, 2023
  • #130

    GCN used for regression(predicting the node score)

    Updated Apr 10, 2023
  • #187

    version of Tensorflow2

    Updated Jun 24, 2022

> Tags

Python

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 2, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言