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/index.md
+10-6Lines changed: 10 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ Usage examples on real datasets can be found in the [examples](https://github.co
26
26
We create a dataset consisting in multiple random graphs and associated data features.
27
27
28
28
```julia
29
-
using GraphNeuralNetworks, Graphs, Flux, CUDA, Statistics
29
+
using GraphNeuralNetworks, Graphs, Flux, CUDA, Statistics, MLUtils
30
30
using Flux.Data: DataLoader
31
31
32
32
all_graphs = GNNGraph[]
@@ -60,13 +60,17 @@ opt = Adam(1f-4)
60
60
### Training
61
61
62
62
Finally, we use a standard Flux training pipeline to fit our dataset.
63
-
Flux's `DataLoader` iterates over mini-batches of graphs
64
-
(batched together into a `GNNGraph` object).
63
+
We use Flux's `DataLoader` to iterate over mini-batches of graphs
64
+
that are glued together into a single `GNNGraph` using the [`MLUtils.batch`](@ref) method. This is what happens under the hood when creating a `DataLoader` with the
ENV["DATADEPS_ALWAYS_ACCEPT"] ="true"# don't ask for dataset download confirmation
34
36
Random.seed!(17) # for reproducibility
@@ -73,8 +75,11 @@ This dataset provides **188 different graphs**, and the task is to classify each
73
75
By inspecting the first graph object of the dataset, we can see that it comes with **17 nodes** and **38 edges**.
74
76
It also comes with exactly **one graph label**, and provides additional node labels (7 classes) and edge labels (4 classes).
75
77
However, for the sake of simplicity, we will not make use of edge labels.
78
+
"""
76
79
77
-
We have some useful utilities for working with graph datasets, *e.g.*, we can shuffle the dataset and use the first 150 graphs as training graphs, while using the remaining ones for testing:
80
+
# ╔═╡ 7f7750ff-b7fa-4fe2-a5a8-6c9c26c479bb
81
+
md"""
82
+
We now convert the MLDatasets.jl graph types to our `GNNGraph`s and we also onehot encode both the node labels (which will be used as input features) and the graph labels (what we want to predict):
y =onehotbatch(dataset.graph_data.targets, [-1, 1])
87
93
end
88
94
95
+
# ╔═╡ 2c6ccfdd-cf11-415b-b398-95e5b0b2bbd4
96
+
md"""We have some useful utilities for working with graph datasets, *e.g.*, we can shuffle the dataset and use the first 150 graphs as training graphs, while using the remaining ones for testing:
Here, we opt for a `batch_size` of 64, leading to 3 (randomly shuffled) mini-batches, containing all ``2 \cdot 64+22 = 150`` graphs.
111
+
"""
112
+
100
113
# ╔═╡ 2a1c501e-811b-4ddd-887b-91e8c929c8b7
101
114
md"""
102
115
## Mini-batching of graphs
@@ -114,35 +127,27 @@ This procedure has some crucial advantages over other batching procedures:
114
127
115
128
2. There is no computational or memory overhead since adjacency matrices are saved in a sparse fashion holding only non-zero entries, *i.e.*, the edges.
116
129
117
-
GNN.jl can **batch multiple graphs into a single giant graph** with the help of Flux's `DataLoader`:
130
+
GNN.jl can **batch multiple graphs into a single giant graph**:
0 commit comments