Releases: EdisonLeeeee/GraphGallery
GraphGallery 0.1.11
update for 0.1.11.
GraphGallery 0.1.10
Changes
- rename
do_forward
totrain_step
andtest_step
- Add datasets support,
Planetoid
andSimpleGraphDataset
:
from graphgallery.data import SimpleGraphDataset, Planetoid
data = Planetoid('cora') # cora, citeseer, pubmed
# or
data = SimpleGraphDataset('cora') # cora, citeseer, pubmed, cora_ml, polblogs
which consists of
adj = data.adj # scipy sprase matrix
x = data.x # numpy array
labels = data.labels # numpy array
idx_train = data.idx_train # numpy array
idx_val = data.idx_val # numpy array
idx_test = data.idx_test # numpy array
for more details, please refer to https://github.com/EdisonLeeeee/GraphData
GraphGallery 0.1.9
Changes
- Add datasets support,
Planetoid
andSimpleGraphDataset
:
from graphgallery.data import SimpleGraphDataset, Planetoid
data = Planetoid('cora') # cora, citeseer, pubmed
# or
data = SimpleGraphDataset('cora') # cora, citeseer, pubmed, cora_ml, polblogs
which consists of
adj = data.adj # scipy sprase matrix
x = data.x # numpy array
labels = data.labels # numpy array
idx_train = data.idx_train # numpy array
idx_val = data.idx_val # numpy array
idx_test = data.idx_test # numpy array
for more details, please refer to https://github.com/EdisonLeeeee/GraphData
GraphGallery 0.1.8
Changes:
- Add DAGNN implementation
- fix some typos
- rewrite
__getattr__
inBaseModel
, so most of the attributes can be used when callingmodel.attr
instead ofmodel.model.attr
, e.g.,model.summary
equalsmodel.model.summary
if has this attributemodel.layers
equalsmodel.model.layers
if has this attributemodel.weights
equalsmodel.model.weights
if has this attribute- others like
get_weights()
,trainable_variables
,variables
are the same
GraphGallery 0.1.7
Changes
New features:
reset_lr
,reset_optimizer
,reset_weights
for semi-supervised models- remove the last softmax activation function, so the output of the model will be a non-activated logit
- add null context manager
- add
Gather
layer
Bug fix
astensor
rename toastensors
and addastensor
methodinfer_type
can accept scipy sparse matrix and tensorflow tensorLGCN
can accept dense matrix- fix
normalize_adj
bug when accept dense matrix
Others
- move
GCNF
,EdgeGCN
,SimplifiedOBVAT
,MedianSAGE
,GCN_MIX
tographgallery/nn/models/semisupervised/experimental/
- by default,
norm_x=None
instead ofnorm_x='l1'
- set default integer type
int32
instead ofint64
Example of GCN model
from graphgallery.nn.models import GCN
# adj is scipy sparse matrix, x is numpy array matrix
model = GCN(adj, x, labels, device='GPU', norm_x='l1', seed=123)
# build your GCN model with custom hyper-parameters
model.build()
# train your model. here idx_train and idx_val are numpy arrays
his = model.train(idx_train, idx_val, verbose=1, epochs=100)
# test your model
loss, accuracy = model.test(idx_test)
print(f'Test loss {loss:.5}, Test accuracy {accuracy:.2%}')
On Cora
dataset:
loss 1.02, acc 95.00%, val_loss 1.41, val_acc 77.40%: 100%|██████████| 100/100 [00:02<00:00, 37.07it/s]
Test loss 1.4123, Test accuracy 81.20%
Build your model
you can use the following statement to build your model
# one hidden layer with hidden units 32 and activation function RELU
>>> model.build(hiddens=32, activations='relu')
# two hidden layer with hidden units 32, 64 and all activation functions are RELU
>>> model.build(hiddens=[32, 64], activations='relu')
# two hidden layer with hidden units 32, 64 and activation functions RELU and ELU
>>> model.build(hiddens=[32, 64], activations=['relu', 'elu'])
# other parameters like `dropouts` and `l2_norms` (if have) are the SAME.
Train or test your model
More details can be seen in the methods model.train and model.test
Hyper-parameters
you can simply use model.show()
to show all your Hyper-parameters
.
Otherwise you can also use model.show('model')
or model.show('train')
to show your model parameters and training parameters.
NOTE: you should install texttable first.
Visualization
- Accuracy
import matplotlib.pyplot as plt
plt.plot(his.history['acc'])
plt.plot(his.history['val_acc'])
plt.legend(['Accuracy', 'Val Accuracy'])
plt.xlabel('Epochs')
- Loss
import matplotlib.pyplot as plt
plt.plot(his.history['loss'])
plt.plot(his.history['val_loss'])
plt.legend(['Loss', 'Val Loss'])
plt.xlabel('Epochs')
GraphGallery 0.1.6
Changes
- rename
SqueezedSparseConversion
-> `SparseConversion`` - rename
norm_adj_rate
->norm_adj
,norm_x_type
->norm_x
- rename
SupervisedModel
->SemiSupervisedModel
- add function
is_scalar_like
- add
__repr__
method forSemiSupervisedModel
andUnsupervisedModel
- fix
tqdm
bug which sometimes show previous results. - fix
astensor
cannot accept scalar bug - fix some typos and bugs
Example of GCN model
from graphgallery.nn.models import GCN
# adj is scipy sparse matrix, x is numpy array matrix
model = GCN(adj, x, labels, device='GPU', seed=123)
# build your GCN model with custom hyper-parameters
model.build()
# train your model. here idx_train and idx_val are numpy arrays
his = model.train(idx_train, idx_val, verbose=1, epochs=100)
# test your model
loss, accuracy = model.test(idx_test)
print(f'Test loss {loss:.5}, Test accuracy {accuracy:.2%}')
On Cora
dataset:
loss 1.02, acc 95.00%, val_loss 1.41, val_acc 77.40%: 100%|██████████| 100/100 [00:02<00:00, 37.07it/s]
Test loss 1.4123, Test accuracy 81.20%
Build your model
you can use the following statement to build your model
# one hidden layer with hidden units 32 and activation function RELU
>>> model.build(hiddens=32, activations='relu')
# two hidden layer with hidden units 32, 64 and all activation functions are RELU
>>> model.build(hiddens=[32, 64], activations='relu')
# two hidden layer with hidden units 32, 64 and activation functions RELU and ELU
>>> model.build(hiddens=[32, 64], activations=['relu', 'elu'])
# other parameters like `dropouts` and `l2_norms` (if have) are the SAME.
Train or test your model
More details can be seen in the methods model.train and model.test
Hyper-parameters
you can simply use model.show()
to show all your Hyper-parameters
.
Otherwise you can also use model.show('model')
or model.show('train')
to show your model parameters and training parameters.
NOTE: you should install texttable first.
Visualization
- Accuracy
import matplotlib.pyplot as plt
plt.plot(his.history['acc'])
plt.plot(his.history['val_acc'])
plt.legend(['Accuracy', 'Val Accuracy'])
plt.xlabel('Epochs')
- Loss
import matplotlib.pyplot as plt
plt.plot(his.history['loss'])
plt.plot(his.history['val_loss'])
plt.legend(['Loss', 'Val Loss'])
plt.xlabel('Epochs')
GraphGallery 0.1.5
Changes
- add
model.show()
methods to show the parameters. - improve the method
model.build
and using it comes more flexible. - fix the
ClusterGCN
retracing intf.function
bugs in tensorflow version >= 2.2.0.
Example of GCN model
from graphgallery.nn.models import GCN
# adj is scipy sparse matrix, x is numpy array matrix
model = GCN(adj, x, labels, device='GPU', seed=123)
# build your GCN model with custom hyper-parameters
model.build()
# train your model. here idx_train and idx_val are numpy arrays
his = model.train(idx_train, idx_val, verbose=1, epochs=100)
# test your model
loss, accuracy = model.test(idx_test)
print(f'Test loss {loss:.5}, Test accuracy {accuracy:.2%}')
On Cora
dataset:
loss 1.02, acc 95.00%, val_loss 1.41, val_acc 77.40%: 100%|██████████| 100/100 [00:02<00:00, 37.07it/s]
Test loss 1.4123, Test accuracy 81.20%
Build your model
you can use the following statement to build your model
# one hidden layer with hidden units 32 and activation function RELU
>>> model.build(hiddens=32, activations='relu')
# two hidden layer with hidden units 32, 64 and all activation functions are RELU
>>> model.build(hiddens=[32, 64], activations='relu')
# two hidden layer with hidden units 32, 64 and activation functions RELU and ELU
>>> model.build(hiddens=[32, 64], activations=['relu', 'elu'])
# other parameters like `dropouts` and `l2_norms` (if have) are the SAME.
Train or test your model
More details can be seen in the methods model.train and model.test
Hyper-parameters
you can simply use model.show()
to show all your Hyper-parameters
.
Otherwise you can also use model.show('model')
or model.show('train')
to show your model parameters and training parameters.
NOTE: you should install texttable first.
Visualization
- Accuracy
import matplotlib.pyplot as plt
plt.plot(his.history['acc'])
plt.plot(his.history['val_acc'])
plt.legend(['Accuracy', 'Val Accuracy'])
plt.xlabel('Epochs')
- Loss
import matplotlib.pyplot as plt
plt.plot(his.history['loss'])
plt.plot(his.history['val_loss'])
plt.legend(['Loss', 'Val Loss'])
plt.xlabel('Epochs')
Graphgallery 0.1.4
Frist stable version of Graphgallery, the following models are implemented:
General models
- GCN from Semi-Supervised Classification with Graph Convolutional Networks 🌐Paper
- GAT from Graph Attention Networks 🌐Paper
- SGC from Simplifying Graph Convolutional Networks 🌐Paper
- GraphSAGE from Inductive Representation Learning on Large Graphs 🌐Paper
- GWNN from Graph Wavelet Neural Network 🌐Paper
- GMNN from Graph Markov Neural Networks 🌐Paper
- ChebyNet from Convolutional Neural Networks on Graphs with Fast Localized Spectral Filtering 🌐Paper
- ClusterGCN from Cluster-GCN: An Efficient Algorithm for Training Deep and Large Graph Convolutional Networks 🌐Paper
- FastGCN from FastGCN: Fast Learning with Graph Convolutional Networks via Importance Sampling 🌐Paper
- LGCN from Large-Scale Learnable Graph Convolutional Networks 🌐Paper
Defense models
- RGCN from Robust Graph Convolutional Networks Against Adversarial Attacks 🌐Paper
- SBVAT/OBVAT from Batch Virtual Adversarial Training for Graph Convolutional Networks 🌐Paper
Other models
- GCN_MIX: Mixture of GCN and MLP
- GCNF: GCN + feature
- DenseGCN: Dense version of GCN
- EdgeGCN: GCN using message passing framework
- MedianSAGE: GraphSAGE using
Median
aggregation