Skip to content

Commit dc47d7f

Browse files
authored
Merge pull request #87 from yuehhua/doc
Add doc for GAE and VGAE
2 parents 689069b + 679bb3d commit dc47d7f

File tree

11 files changed

+232
-10
lines changed

11 files changed

+232
-10
lines changed

docs/make.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ makedocs(
66
format = Documenter.HTML(),
77
modules = [GeometricFlux],
88
pages = ["Home" => "index.md",
9+
"Get started" => "start.md",
10+
"Basics" =>
11+
["Building layers" => "basics/layers.md",
12+
"Graph passing" => "basics/passgraph.md"],
13+
"Abstractions" =>
14+
["Message passing scheme" => "abstractions/msgpass.md",
15+
"Graph network block" => "abstractions/gn.md"],
916
"Manual" =>
1017
["Convolutional Layers" => "manual/conv.md",
1118
"Pooling Layers" => "manual/pool.md",

docs/src/abstractions/gn.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Graph network block

docs/src/abstractions/msgpass.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Message passing scheme

docs/src/basics/layers.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Building layers

docs/src/basics/passgraph.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Graph passing
2+
3+
Graph is an input data structure for graph neural network. Passing graph and input feature into
4+
5+
## Static graph
6+
7+
## Variable graph
8+
9+
## Cached graph

docs/src/index.md

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# GeometricFlux: The Geometric Deep Learning Library in Julia
22

3-
Documentation for GeometricFlux.jl
3+
GeometricFlux is a framework for geometric deep learning/machine learning.
4+
5+
* It extends Flux machine learning library for geometric deep learning.
6+
* It supports of CUDA GPU with CUDA.jl
7+
* It integrates with JuliaGraphs ecosystems.
8+
* It supports generic graph neural network architectures (i.g. message passing scheme and graph network block)
9+
* It contains built-in GNN benchmark datasets (WIP)
410

511
## Installation
612

@@ -9,3 +15,99 @@ Documentation for GeometricFlux.jl
915
```
1016

1117
## Quick start
18+
19+
The basic graph convolutional network (GCN) is constructed as follow.
20+
21+
```
22+
model = Chain(GCNConv(adj_mat, num_features=>hidden, relu),
23+
GCNConv(adj_mat, hidden=>target_catg),
24+
softmax)
25+
```
26+
27+
### Load dataset
28+
29+
Load cora dataset from GeometricFlux.
30+
31+
```
32+
using JLD2
33+
using SparseArrays
34+
35+
@load joinpath(pkgdir(GeometricFlux), "data/cora_features.jld2") features
36+
@load joinpath(pkgdir(GeometricFlux), "data/cora_labels.jld2") labels
37+
@load joinpath(pkgdir(GeometricFlux), "data/cora_graph.jld2") g
38+
```
39+
40+
### Training/testing data
41+
42+
Data is stored in sparse array, thus, we have to convert it into normal array.
43+
44+
```
45+
train_X = Matrix{Float32}(features)
46+
train_y = Matrix{Float32}(labels)
47+
adj_mat = Matrix{Float32}(adjacency_matrix(g))
48+
```
49+
50+
### Loss function
51+
52+
```
53+
loss(x, y) = logitcrossentropy(model(x), y)
54+
accuracy(x, y) = mean(onecold(model(x)) .== onecold(y))
55+
```
56+
57+
### Training
58+
59+
```
60+
ps = Flux.params(model)
61+
train_data = [(train_X, train_y)]
62+
opt = ADAM()
63+
evalcb() = @show(accuracy(train_X, train_y))
64+
65+
@epochs epochs Flux.train!(loss, ps, train_data, opt, cb=throttle(evalcb, 10))
66+
```
67+
68+
### Logs
69+
70+
```
71+
[ Info: Epoch 1
72+
accuracy(train_X, train_y) = 0.11669128508124077
73+
[ Info: Epoch 2
74+
accuracy(train_X, train_y) = 0.19608567208271788
75+
[ Info: Epoch 3
76+
accuracy(train_X, train_y) = 0.3098227474150665
77+
[ Info: Epoch 4
78+
accuracy(train_X, train_y) = 0.387370753323486
79+
[ Info: Epoch 5
80+
accuracy(train_X, train_y) = 0.44645494830132937
81+
[ Info: Epoch 6
82+
accuracy(train_X, train_y) = 0.46824224519940916
83+
[ Info: Epoch 7
84+
accuracy(train_X, train_y) = 0.48892171344165436
85+
[ Info: Epoch 8
86+
accuracy(train_X, train_y) = 0.5025849335302807
87+
[ Info: Epoch 9
88+
accuracy(train_X, train_y) = 0.5151403249630724
89+
[ Info: Epoch 10
90+
accuracy(train_X, train_y) = 0.5291728212703102
91+
[ Info: Epoch 11
92+
accuracy(train_X, train_y) = 0.543205317577548
93+
[ Info: Epoch 12
94+
accuracy(train_X, train_y) = 0.5550221565731167
95+
[ Info: Epoch 13
96+
accuracy(train_X, train_y) = 0.5638847858197932
97+
[ Info: Epoch 14
98+
accuracy(train_X, train_y) = 0.5657311669128509
99+
[ Info: Epoch 15
100+
accuracy(train_X, train_y) = 0.5749630723781388
101+
[ Info: Epoch 16
102+
accuracy(train_X, train_y) = 0.5834564254062038
103+
[ Info: Epoch 17
104+
accuracy(train_X, train_y) = 0.5919497784342689
105+
[ Info: Epoch 18
106+
accuracy(train_X, train_y) = 0.5978581979320532
107+
[ Info: Epoch 19
108+
accuracy(train_X, train_y) = 0.6019202363367799
109+
[ Info: Epoch 20
110+
accuracy(train_X, train_y) = 0.6067208271787297
111+
```
112+
113+
Check `examples/gcn.jl` for details.

docs/src/manual/linalg.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33

44
```@docs
5-
GeometricFlux.degrees
5+
GraphSignals.degrees
66
```
77

88
```@docs
9-
GeometricFlux.degree_matrix
9+
GraphSignals.degree_matrix
1010
```
1111

1212
```@docs
13-
GeometricFlux.inv_sqrt_degree_matrix
13+
GraphSignals.inv_sqrt_degree_matrix
1414
```
1515

1616
```@docs
17-
GeometricFlux.laplacian_matrix
17+
GraphSignals.laplacian_matrix
1818
```
1919

2020
```@docs
21-
GeometricFlux.normalized_laplacian
21+
GraphSignals.normalized_laplacian
2222
```

docs/src/manual/models.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,68 @@
11
# Models
2+
3+
## Autoencoders
4+
5+
### Graph Autoencoder
6+
7+
```math
8+
Z = enc(X, A) \\
9+
\hat{A} = \sigma (ZZ^T)
10+
```
11+
12+
where ``A`` denotes the adjacency matrix.
13+
14+
```@docs
15+
GAE
16+
```
17+
18+
Reference: [Variational Graph Auto-Encoders](https://arxiv.org/abs/1611.07308)
19+
20+
---
21+
22+
### Variational Graph Autoencoder
23+
24+
```math
25+
X' = \sigma(\hat{D}^{-1/2} \hat{A} \hat{D}^{-1/2} X \Theta)
26+
```
27+
28+
where ``\hat{A} = A + I``, ``A`` denotes the adjacency matrix, and
29+
``\hat{D} = [\hat{d}_{ij}] = \sum_{j=0} [\hat{a}_{ij}]`` is degree matrix.
30+
31+
```@docs
32+
VGAE
33+
```
34+
35+
Reference: [Variational Graph Auto-Encoders](https://arxiv.org/abs/1611.07308)
36+
37+
---
38+
39+
## Special Layers
40+
41+
### Inner-product Decoder
42+
43+
```math
44+
\hat{A} = \sigma (ZZ^T)
45+
```
46+
47+
where ``Z`` denotes the input matrix from encoder.
48+
49+
```@docs
50+
InnerProductDecoder
51+
```
52+
53+
Reference: [Variational Graph Auto-Encoders](https://arxiv.org/abs/1611.07308)
54+
55+
---
56+
57+
### Variational Encoder
58+
59+
```math
60+
H = f(X)
61+
μ, logσ = μ(H), Σ(H)
62+
```
63+
64+
```@docs
65+
VariationalEncoder
66+
```
67+
68+
Reference: [Variational Graph Auto-Encoders](https://arxiv.org/abs/1611.07308)

docs/src/manual/utils.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
11
# Utilities
2-
3-
```@docs
4-
GeometricFlux.save_div
5-
```

docs/src/start.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Get started

0 commit comments

Comments
 (0)