Skip to content

A gallery of state-of-the-arts deep learning graph models. Implemented with Tensorflow 2.x.

Notifications You must be signed in to change notification settings

voladorlu/graphgallery

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents

GraphGallery

Back to TOC

A gallery of state-of-the-arts deep learning graph models.

Implemented with Tensorflow 2.x.

This repo aims to achieve 4 goals:

  • Similar (or higher) performance with the corresponding papers
  • Faster implementation of training and testing
  • Simple and convenient to use with high scalability
  • Easy to read source codes

Requirements

Back to TOC

  • python>=3.7
  • tensorflow>=2.1
  • networkx==2.3
  • metis==0.2a4
  • scipy>=1.4.1
  • sklearn>=0.22
  • numpy>=1.18.1
  • numba>=0.48
  • gensim>=3.8.1

Usage

Back to TOC

Inputs

adj: `scipy.sparse.csr_matrix` (or `csc_matrix`) with shape (N, N)
    The input `symmetric` adjacency matrix, where `N` is the number of nodes 
    in graph.
features: `np.array` with shape (N, F)
    The input node feature matrix, where `F` is the dimension of node features.
labels: `np.array` with shape (N,)
    The ground-truth labels for all nodes in graph.
normalize_rate (Float scalar, optional): 
    The normalize rate for adjacency matrix `adj`. (default: :obj:`-0.5`, 
    i.e., math:: \hat{A} = D^{-\frac{1}{2}} A D^{-\frac{1}{2}}) 
normalize_features (Boolean, optional): 
    Whether to use row-normalize for node feature matrix. 
    (default :obj: `True`)
device (String, optional): 
    The device where the model is running on. You can specified `CPU` or `GPU` 
    for the model. (default: :obj: `CPU:0`, i.e., the model is running on 
    the 0-th device `CPU`)
seed (Positive integer, optional): 
    Used in combination with `tf.random.set_seed & np.random.seed & random.seed` 
    to create a reproducible sequence of tensors across multiple calls. 
    (default :obj: `None`, i.e., using random seed)
name (String, optional): 
    Name for the model. (default: name of class)

You can specified customized hyperparameters and training details by calling model.build(your_args) and model.trian(your_args). The usuage documents will be gradually added later.

GCN

from graphgallery.nn.models import GCN
model = GCN(adj, features, labels, device='CPU', seed=123)
model.build()
his = model.train(idx_train, idx_val, verbose=True, epochs=100)
loss, accuracy = model.test(idx_test)
model.close
print(f'Test loss {loss:.5}, Test accuracy {accuracy:.2%}')

DenceGCN

Dense version of GCN, i.e., the adj will be transformed to Tensor instead of SparseTensor.

from graphgallery.nn.models import DenseGCN
model = DenseGCN(adj, features, labels, device='CPU', seed=123)
model.build()
his = model.train(idx_train, idx_val, verbose=True, epochs=100)
loss, accuracy = model.test(idx_test)
model.close
print(f'Test loss {loss:.5}, Test accuracy {accuracy:.2%}')

ChebyNet

from graphgallery.nn.models import ChebyNet
model = ChebyNet(adj, features, labels, order=2, device='CPU', seed=123)
model.build()
his = model.train(idx_train, idx_val, verbose=True, epochs=100)
loss, accuracy = model.test(idx_test)
model.close
print(f'Test loss {loss:.5}, Test accuracy {accuracy:.2%}')

FastGCN

from graphgallery.nn.models import FastGCN
model = FastGCN(adj, features, labels, device='CPU', seed=123)
model.build()
his = model.train(idx_train, idx_val, verbose=True, epochs=100)
loss, accuracy = model.test(idx_test)
model.close
print(f'Test loss {loss:.5}, Test accuracy {accuracy:.2%}')

GraphSAGE

from graphgallery.nn.models import GraphSAGE
model = GraphSAGE(adj, features, labels, n_samples=[10, 5], device='CPU', seed=123)
model.build()
his = model.train(idx_train, idx_val, verbose=True, epochs=100, restore_best=False, validation=False)
loss, accuracy = model.test(idx_test)
model.close
print(f'Test loss {loss:.5}, Test accuracy {accuracy:.2%}')

RobustGCN

from graphgallery.nn.models import RobustGCN
model = RobustGCN(adj, features, labels, device='CPU', seed=123)
model.build()
his = model.train(idx_train, idx_val, verbose=True, epochs=100)
loss, accuracy = model.test(idx_test)
model.close
print(f'Test loss {loss:.5}, Test accuracy {accuracy:.2%}')

SGC

from graphgallery.nn.models import SGC
model = SGC(adj, features, labels, device='CPU', seed=123)
model.build()
his = model.train(idx_train, idx_val, verbose=True, epochs=100)
loss, accuracy = model.test(idx_test)
model.close
print(f'Test loss {loss:.5}, Test accuracy {accuracy:.2%}')

GWNN

from graphgallery.nn.models import GWNN
model = GWNN(adj, features, labels, device='CPU', seed=123)
model.build()
his = model.train(idx_train, idx_val, verbose=True, epochs=100)
loss, accuracy = model.test(idx_test)
model.close
print(f'Test loss {loss:.5}, Test accuracy {accuracy:.2%}')

GAT

from graphgallery.nn.models import GAT
model = GAT(adj, features, labels, device='CPU', seed=123)
model.build()
his = model.train(idx_train, idx_val, verbose=True, epochs=200)
loss, accuracy = model.test(idx_test)
model.close
print(f'Test loss {loss:.5}, Test accuracy {accuracy:.2%}')

ClusterGCN

from graphgallery.nn.models import ClusterGCN
model = ClusterGCN(Data.adj, Data.features, data.labels, n_cluster=10, device='CPU', seed=123)
model.build()
his = model.train(idx_train, idx_val, verbose=True, epochs=100)
loss, accuracy = model.test(idx_test)
model.close
print(f'Test loss {loss:.5}, Test accuracy {accuracy:.2%}')

SBVAT

from graphgallery.nn.models import SBVAT
model = GMNN(adj, features, labels, device='CPU', seed=123)
model.build()
his = model.train(idx_train, idx_val, verbose=True, epochs=100)
loss, accuracy = model.test(idx_test)
model.close
print(f'Test loss {loss:.5}, Test accuracy {accuracy:.2%}')

OBVAT

from graphgallery.nn.models import OBVAT
model = OBVAT(adj, features, labels, device='CPU', seed=123)
model.build()
his = model.train(idx_train, idx_val, verbose=True, epochs=100)
loss, accuracy = model.test(idx_test)
model.close
print(f'Test loss {loss:.5}, Test accuracy {accuracy:.2%}')

GMNN

from graphgallery.nn.models import GMNN
model = GMNN(adj, features, labels, device='CPU', seed=123)
model.build()
his = model.train(idx_train, idx_val, verbose=True, epochs=100)
loss, accuracy = model.test(idx_test)
model.close
print(f'Test loss {loss:.5}, Test accuracy {accuracy:.2%}')

LGCN

from graphgallery.nn.models import LGCN
model = GMNN(adj, features, labels, device='CPU', seed=123)
model.build()
his = model.train(idx_train, idx_val, verbose=True, epochs=100)
loss, accuracy = model.test(idx_test)
model.close
print(f'Test loss {loss:.5}, Test accuracy {accuracy:.2%}')

Deepwalk

from graphgallery.nn.models import Deepwalk
model = Deepwalk(adj, features, labels)
model.build()
model.train(idx_train)
accuracy = model.test(idx_test)
print(f'Test accuracy {accuracy:.2%}')

Node2vec

from graphgallery.nn.models import Node2vec
model = Node2vec(adj, features, labels)
model.build()
model.train(idx_train)
accuracy = model.test(idx_test)
print(f'Test accuracy {accuracy:.2%}')

About

A gallery of state-of-the-arts deep learning graph models. Implemented with Tensorflow 2.x.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%