Skip to content

Commit 90397ab

Browse files
minor doc improve (#73)
* doc improves
1 parent 069424f commit 90397ab

File tree

3 files changed

+41
-12
lines changed

3 files changed

+41
-12
lines changed

docs/src/api/gnngraph.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,9 @@ CurrentModule = GraphNeuralNetworks
66

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

9-
```@contents
10-
Pages = ["gnngraph.md"]
11-
Depth = 5
12-
```
13-
149
Besides the methods documented here, one can rely on the large set of functionalities
15-
given by [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl)
16-
since `GNNGraph` inherits from `Graphs.AbstractGraph`.
10+
given by [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl) thanks to the fact
11+
that `GNNGraph` inherits from `Graphs.AbstractGraph`.
1712

1813
## Index
1914

@@ -60,3 +55,15 @@ Modules = [GraphNeuralNetworks.GNNGraphs]
6055
Pages = ["generate.jl"]
6156
Private = false
6257
```
58+
59+
## Operators
60+
61+
```@autodocs
62+
Modules = [GraphNeuralNetworks.GNNGraphs]
63+
Pages = ["operators.jl"]
64+
Private = false
65+
```
66+
67+
```@docs
68+
Graphs.intersect
69+
```

docs/src/messagepassing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ julia> apply_edges((xi, xj, e) -> xi.a + xi.b .* xj, g, xi=(a=x,b=z), xj=z)
7272
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
7373
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
7474
```
75-
The function [@propagate](@ref) instead performs also the the [`apply_edges`](@ref) operation
76-
but then applies a reduction over each node's neighborhood.
75+
The function [`propagate`](@ref) instead performs the [`apply_edges`](@ref) operation
76+
but then also applies a reduction over each node's neighborhood.
7777
```julia
7878
julia> propagate((xi, xj, e) -> xi .+ xj, g, +, xi=x, xj=z)
7979
2×10 Matrix{Float64}:

docs/src/models.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Models
22

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

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

55-
g = GNNGraph(random_regular_graph(10, 4))
55+
g = rand_graph(10, 30)
5656
X = randn(Float32, din, 10)
5757

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

7676
din, d, dout = 3, 4, 2
77-
g = GNNGraph(random_regular_graph(10, 4))
77+
g = rand_graph(10, 30)
7878
X = randn(Float32, din, 10)
7979

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

102102
y = model(g, X) # output size: (dout, g.num_graphs)
103103
```
104+
105+
## Embedding a graph in the model
106+
107+
Sometimes it is useful to consider a specific graph as a part of a model instead of
108+
its input. GNN.jl provides the [`WithGraph`](@ref) type to deal with this scenario.
109+
110+
```julia
111+
chain = GNNChain(GCNConv(din => d, relu),
112+
GCNConv(d => d))
113+
114+
115+
g = rand_graph(10, 30)
116+
117+
model = WithGraph(chain, g)
118+
119+
X = randn(Float32, din, 10)
120+
121+
# Pass only X as input, the model already contains the graph.
122+
y = model(X)
123+
```
124+
125+
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.

0 commit comments

Comments
 (0)