Skip to content

Commit 318d8ba

Browse files
simplify documentation
1 parent 2eddfc8 commit 318d8ba

File tree

5 files changed

+92
-128
lines changed

5 files changed

+92
-128
lines changed

GraphNeuralNetworks/docs/make.jl

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,19 @@ makedocs(;
2121
plugins = [interlinks],
2222
format = Documenter.HTML(; mathengine, prettyurls, assets = assets, size_threshold=nothing),
2323
sitename = "GraphNeuralNetworks.jl",
24-
pages = ["Monorepo" => [
25-
"Home" => "index.md",
26-
"Developer guide" => "dev.md",
27-
"Google Summer of Code" => "gsoc.md",
24+
pages = [
25+
"Home" => "index.md",
26+
"Guides" => [
27+
"Models" => "models.md",
2828
],
29-
"GraphNeuralNetworks.jl" =>[
30-
"Home" => "home.md",
31-
"Models" => "models.md",],
32-
3329
"API Reference" => [
34-
3530
"Basic" => "api/basic.md",
3631
"Convolutional layers" => "api/conv.md",
3732
"Pooling layers" => "api/pool.md",
3833
"Temporal Convolutional layers" => "api/temporalconv.md",
3934
"Hetero Convolutional layers" => "api/heteroconv.md",
40-
41-
4235
],
36+
"Developer guide" => "dev.md",
4337

4438
],
4539
)

GraphNeuralNetworks/docs/src/gsoc.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

GraphNeuralNetworks/docs/src/home.md

Lines changed: 0 additions & 87 deletions
This file was deleted.

GraphNeuralNetworks/docs/src/index.md

Lines changed: 84 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,107 @@
1-
# GraphNeuralNetworks Monorepo
1+
# GraphNeuralNetworks
22

3-
This is the monorepository for the GraphNeuralNetworks project, bringing together all code into a unified structure to facilitate code sharing and reusability across different project components. It contains the following packages:
3+
GraphNeuralNetworks.jl is a graph neural network package based on the deep learning framework [Flux.jl](https://github.com/FluxML/Flux.jl).
44

5-
- `GraphNeuralNetwork.jl`: Package that contains stateful graph convolutional layers based on the machine learning framework [Flux.jl](https://fluxml.ai/Flux.jl/stable/). This is fronted package for Flux users. It depends on GNNlib.jl, GNNGraphs.jl, and Flux.jl packages.
5+
It provides a set of stateful graph convolutional layers and utilities to build graph neural networks.
66

7-
- `GNNLux.jl`: Package that contains stateless graph convolutional layers based on the machine learning framework [Lux.jl](https://lux.csail.mit.edu/stable/). This is fronted package for Lux users. It depends on GNNlib.jl, GNNGraphs.jl, and Lux.jl packages.
7+
Among its features:
88

9-
- `GNNlib.jl`: Package that contains the core graph neural network layers and utilities. It depends on GNNGraphs.jl and GNNlib.jl packages and serves for code base for GraphNeuralNetwork.jl and GNNLux.jl packages.
10-
11-
- `GNNGraphs.jl`: Package that contains the graph data structures and helper functions for working with graph data. It depends on Graphs.jl package.
12-
13-
Here is a schema of the dependencies between the packages:
14-
15-
![Monorepo schema](assets/schema.png)
16-
17-
18-
Among its general features:
19-
20-
* Implements common graph convolutional layers both in stateful and stateless form.
9+
* Implements common graph convolutional layers.
2110
* Supports computations on batched graphs.
2211
* Easy to define custom layers.
2312
* CUDA support.
2413
* Integration with [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl).
2514
* [Examples](https://github.com/JuliaGraphs/GraphNeuralNetworks.jl/tree/master/GraphNeuralNetworks/examples) of node, edge, and graph level machine learning tasks.
26-
* Heterogeneous and temporal graphs.
15+
* Heterogeneous and temporal graphs.
16+
17+
The package is part of a larger ecosystem of packages that includes [GNNlib.jl](https://juliagraphs.org/GraphNeuralNetworks.jl/gnnlib), [GNNGraphs.jl](https://juliagraphs.org/GraphNeuralNetworks.jl/gnngraphs), and [GNNLux.jl](https://juliagraphs.org/GraphNeuralNetworks.jl/gnnlux).
18+
19+
GraphNeuralNetworks.jl is the fronted package for Flux.jl users. [Lux.jl](https://lux.csail.mit.edu/stable/) users instead, can relyi on GNNLux.jl (still in development).
2720

2821
## Installation
2922

30-
GraphNeuralNetworks.jl, GNNlib.jl and GNNGraphs.jl are a registered Julia packages. You can easily install a package, for example GraphNeuralNetworks.jl, through the package manager :
23+
GraphNeuralNetworks.jl is a registered Julia package. You can easily install it through the package manager :
3124

3225
```julia
3326
pkg> add GraphNeuralNetworks
3427
```
3528

36-
## Usage
29+
## Package overview
30+
31+
Let's give a brief overview of the package by solving a graph regression problem with synthetic data.
32+
33+
Other usage examples can be found in the [examples](https://github.com/JuliaGraphs/GraphNeuralNetworks.jl/tree/master/GraphNeuralNetworks/examples) folder, in the [notebooks](https://github.com/JuliaGraphs/GraphNeuralNetworks.jl/tree/master/GraphNeuralNetworks/notebooks) folder, and in the [tutorials](https://juliagraphs.org/GraphNeuralNetworks.jl/tutorials/) section of the documentation.
34+
35+
### Data preparation
36+
37+
We create a dataset consisting in multiple random graphs and associated data features.
38+
39+
```julia
40+
using GraphNeuralNetworks, Flux, CUDA, Statistics, MLUtils
41+
using Flux: DataLoader
42+
43+
all_graphs = GNNGraph[]
44+
45+
for _ in 1:1000
46+
g = rand_graph(10, 40,
47+
ndata=(; x = randn(Float32, 16,10)), # Input node features
48+
gdata=(; y = randn(Float32))) # Regression target
49+
push!(all_graphs, g)
50+
end
51+
```
52+
53+
### Model building
3754

38-
Usage examples can be found in the [examples](https://github.com/JuliaGraphs/GraphNeuralNetworks.jl/tree/master/GraphNeuralNetworks/examples) and in the [notebooks](https://github.com/JuliaGraphs/GraphNeuralNetworks.jl/tree/master/GraphNeuralNetworks/notebooks) folder. Also, make sure to read the [documentation](https://juliagraphs.org/GraphNeuralNetworks.jl/graphneuralnetworks/) for a comprehensive introduction to the library and the [tutorials](https://juliagraphs.org/GraphNeuralNetworks.jl/tutorials/).
55+
We concisely define our model as a [`GraphNeuralNetworks.GNNChain`](@ref) containing two graph convolutional layers. If CUDA is available, our model will live on the gpu.
3956

4057

58+
```julia
59+
device = CUDA.functional() ? Flux.gpu : Flux.cpu;
60+
61+
model = GNNChain(GCNConv(16 => 64),
62+
BatchNorm(64), # Apply batch normalization on node features (nodes dimension is batch dimension)
63+
x -> relu.(x),
64+
GCNConv(64 => 64, relu),
65+
GlobalPool(mean), # Aggregate node-wise features into graph-wise features
66+
Dense(64, 1)) |> device
67+
68+
opt = Flux.setup(Adam(1f-4), model)
69+
```
70+
71+
### Training
72+
73+
Finally, we use a standard Flux training pipeline to fit our dataset.
74+
We use Flux's `DataLoader` to iterate over mini-batches of graphs
75+
that are glued together into a single `GNNGraph` using the `MLUtils.batch` method. This is what happens under the hood when creating a `DataLoader` with the
76+
`collate=true` option.
77+
78+
```julia
79+
train_graphs, test_graphs = MLUtils.splitobs(all_graphs, at=0.8)
80+
81+
train_loader = DataLoader(train_graphs,
82+
batchsize=32, shuffle=true, collate=true)
83+
test_loader = DataLoader(test_graphs,
84+
batchsize=32, shuffle=false, collate=true)
85+
86+
loss(model, g::GNNGraph) = mean((vec(model(g, g.x)) - g.y).^2)
87+
88+
loss(model, loader) = mean(loss(model, g |> device) for g in loader)
89+
90+
for epoch in 1:100
91+
for g in train_loader
92+
g = g |> device
93+
grad = gradient(model -> loss(model, g), model)
94+
Flux.update!(opt, model, grad[1])
95+
end
96+
97+
@info (; epoch, train_loss=loss(model, train_loader), test_loss=loss(model, test_loader))
98+
end
99+
```
100+
101+
# Google Summer of Code
102+
103+
Potential candidates to Google Summer of Code's scholarships can find out about the available projects involving GraphNeuralNetworks.jl on the [dedicated page](https://julialang.org/jsoc/gsoc/gnn/) in the Julia Language website.
104+
41105
## Citing
42106

43107
If you use GraphNeuralNetworks.jl in a scientific publication, we would appreciate the following reference:
@@ -57,7 +121,3 @@ GraphNeuralNetworks.jl is largely inspired by [PyTorch Geometric](https://pytorc
57121
and [GeometricFlux.jl](https://fluxml.ai/GeometricFlux.jl/stable/).
58122

59123

60-
61-
62-
63-

docs/make-multi.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ docs = [
1515
MultiDocumenter.MultiDocRef(
1616
upstream = joinpath(dirname(@__DIR__),"GraphNeuralNetworks", "docs", "build"),
1717
path = "graphneuralnetworks",
18-
name = "GraphNeuralNetworks",
18+
name = "GraphNeuralNetworks.jl",
1919
fix_canonical_url = false),
2020
MultiDocumenter.MultiDocRef(
2121
upstream = joinpath(dirname(@__DIR__), "GNNGraphs", "docs", "build"),
2222
path = "gnngraphs",
23-
name = "GNNGraphs",
23+
name = "GNNGraphs.jl",
2424
fix_canonical_url = false),
2525
MultiDocumenter.MultiDocRef(
2626
upstream = joinpath(dirname(@__DIR__), "GNNlib", "docs", "build"),
2727
path = "gnnlib",
28-
name = "GNNlib",
28+
name = "GNNlib.jl",
2929
fix_canonical_url = false),
3030
MultiDocumenter.MultiDocRef(
3131
upstream = joinpath(dirname(@__DIR__), "GNNLux", "docs", "build"),

0 commit comments

Comments
 (0)