Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor doc improve #73

Merged
merged 3 commits into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions docs/src/api/gnngraph.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@ CurrentModule = GraphNeuralNetworks

Documentation page for the graph type `GNNGraph` provided by GraphNeuralNetworks.jl and related methods.

```@contents
Pages = ["gnngraph.md"]
Depth = 5
```

Besides the methods documented here, one can rely on the large set of functionalities
given by [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl)
since `GNNGraph` inherits from `Graphs.AbstractGraph`.
given by [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl) thanks to the fact
that `GNNGraph` inherits from `Graphs.AbstractGraph`.

## Index

Expand Down Expand Up @@ -60,3 +55,15 @@ Modules = [GraphNeuralNetworks.GNNGraphs]
Pages = ["generate.jl"]
Private = false
```

## Operators

```@autodocs
Modules = [GraphNeuralNetworks.GNNGraphs]
Pages = ["operators.jl"]
Private = false
```

```@docs
Graphs.intersect
```
4 changes: 2 additions & 2 deletions docs/src/messagepassing.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ julia> apply_edges((xi, xj, e) -> xi.a + xi.b .* xj, g, xi=(a=x,b=z), xj=z)
5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0
5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0
```
The function [@propagate](@ref) instead performs also the the [`apply_edges`](@ref) operation
but then applies a reduction over each node's neighborhood.
The function [`propagate`](@ref) instead performs the [`apply_edges`](@ref) operation
but then also applies a reduction over each node's neighborhood.
```julia
julia> propagate((xi, xj, e) -> xi .+ xj, g, +, xi=x, xj=z)
2×10 Matrix{Float64}:
Expand Down
28 changes: 25 additions & 3 deletions docs/src/models.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Models

GraphNeuralNetworks.jl provides common graph convolutional layers by which you can assemble arbitrarily deep or complex models. GNN layers are compatible with
Flux.jl ones, therefore expert Flux's users should be immediately able to define and train
Flux.jl ones, therefore expert Flux users are promptly able to define and train
their models.

In what follows, we discuss two different styles for model creation:
Expand Down Expand Up @@ -52,7 +52,7 @@ end
din, d, dout = 3, 4, 2
model = GNN(din, d, dout) # step 5

g = GNNGraph(random_regular_graph(10, 4))
g = rand_graph(10, 30)
X = randn(Float32, din, 10)

y = model(g, X) # output size: (dout, g.num_nodes)
Expand All @@ -74,7 +74,7 @@ Using `GNNChain`, the previous example becomes
using Flux, Graphs, GraphNeuralNetworks

din, d, dout = 3, 4, 2
g = GNNGraph(random_regular_graph(10, 4))
g = rand_graph(10, 30)
X = randn(Float32, din, 10)

model = GNNChain(GCNConv(din => d),
Expand All @@ -101,3 +101,25 @@ model = GNNChain( ResGatedGraphConv(din => d, relu),

y = model(g, X) # output size: (dout, g.num_graphs)
```

## Embedding a graph in the model

Sometimes it is useful to consider a specific graph as a part of a model instead of
its input. GNN.jl provides the [`WithGraph`](@ref) type to deal with this scenario.

```julia
chain = GNNChain(GCNConv(din => d, relu),
GCNConv(d => d))


g = rand_graph(10, 30)

model = WithGraph(chain, g)

X = randn(Float32, din, 10)

# Pass only X as input, the model already contains the graph.
y = model(X)
```

An example of `WithGraph` usage is given in the graph neural ODE script in the [examples](https://github.com/CarloLucibello/GraphNeuralNetworks.jl/tree/master/examples) folder.