You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/models.md
+25-3Lines changed: 25 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Models
2
2
3
3
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
5
5
their models.
6
6
7
7
In what follows, we discuss two different styles for model creation:
@@ -52,7 +52,7 @@ end
52
52
din, d, dout =3, 4, 2
53
53
model =GNN(din, d, dout) # step 5
54
54
55
-
g =GNNGraph(random_regular_graph(10, 4))
55
+
g =rand_graph(10, 30)
56
56
X =randn(Float32, din, 10)
57
57
58
58
y =model(g, X) # output size: (dout, g.num_nodes)
@@ -74,7 +74,7 @@ Using `GNNChain`, the previous example becomes
y =model(g, X) # output size: (dout, g.num_graphs)
103
103
```
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