Skip to content

Commit db9de4d

Browse files
polishing all
1 parent b52d7d4 commit db9de4d

File tree

7 files changed

+694
-54
lines changed

7 files changed

+694
-54
lines changed

docs/Project.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
33
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
4-
GraphMakie = "1ecd5474-83a3-4783-bb4f-06765db800d2"
54
GraphNeuralNetworks = "cffab07f-9bc2-4db1-8861-388f63bf7694"
65
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
76
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
8-
MLDatasets = "eb30cadb-4394-5ae3-aed4-317e484a6458"
7+
MarkdownLiteral = "736d6165-7244-6769-4267-6b50796e6954"
98
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
10-
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
119
Pluto = "c3e4b0f8-55cb-11ea-2926-15256bba5781"
1210
PlutoStaticHTML = "359b1769-a58e-495b-9770-312e911026ad"
1311
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1412
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1513
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
16-
WGLMakie = "276b4fcb-3e11-5398-bf8b-a0c2d153d008"

docs/make.jl

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,44 @@
11
using Flux, NNlib, GraphNeuralNetworks, Graphs, SparseArrays
22
using Documenter
3+
4+
# See this for a template of Pluto+Documenter
5+
# https://github.com/rikhuijzer/PlutoStaticHTML.jl/blob/main/docs/make.jl
36
using Pluto, PlutoStaticHTML
7+
using Documenter: MathJax3
48

5-
TutorialMenu = Array{Pair{String,String},1}()
9+
tutorial_menu = Array{Pair{String,String},1}()
610

711
#
812
# Generate Pluto Tutorial HTMLs
913

1014
# First tutorial with AD
11-
pluto_src_folder = joinpath(@__DIR__, "tutorials/")
12-
pluto_output_folder = joinpath(@__DIR__, "tutorials/")
15+
pluto_src_folder = joinpath(@__DIR__, "src", "tutorials")
16+
pluto_output_folder = joinpath(@__DIR__, "src", "tutorials")
1317
pluto_relative_path = "tutorials/"
1418
mkpath(pluto_output_folder)
15-
#
16-
#
19+
20+
# """
21+
# build()
22+
# Run all Pluto notebooks (".jl" files) in `NOTEBOOK_DIR`.
23+
# """
24+
# function build()
25+
# println("Building notebooks")
26+
# hopts = HTMLOptions(; append_build_context=true)
27+
# output_format = documenter_output
28+
# bopts = BuildOptions(pluto_src_folder; output_format)
29+
# build_notebooks(bopts, hopts)
30+
# return nothing
31+
# end
32+
33+
# # Build the notebooks; defaults to true.
34+
# if get(ENV, "BUILD_DOCS_NOTEBOOKS", "true") == "true"
35+
# build()
36+
# end
37+
1738
# Please do not use the same name as for a(n old) literate Tutorial
1839
pluto_files = [
19-
"gnn_intro.pluto",
20-
"graph_classification.pluto",
40+
"gnn_intro_pluto",
41+
"graph_classification_pluto",
2142
]
2243
pluto_titles = [
2344
"Intro to Graph Neural Networks ",
@@ -26,7 +47,7 @@ pluto_titles = [
2647

2748
# build menu and write files myself - tp set edit url correctly.
2849
for (title, file) in zip(pluto_titles, pluto_files)
29-
global TutorialMenu
50+
global tutorial_menu
3051
rendered = build_notebooks( #though not really parallel here
3152
BuildOptions(
3253
pluto_src_folder;
@@ -37,30 +58,41 @@ for (title, file) in zip(pluto_titles, pluto_files)
3758
["$(file).jl"],
3859
)
3960
write(
40-
pluto_output_folder * file * ".md",
61+
joinpath(pluto_output_folder, file * ".md"),
4162
"""
4263
```@meta
43-
EditURL = "$(pluto_src_folder)$(file).jl"
64+
EditURL = "$(joinpath(pluto_src_folder, file * ".jl"))"
4465
```
4566
$(rendered[1])
4667
""",
4768
)
48-
push!(TutorialMenu, title => joinpath(pluto_relative_path, file * ".md"))
69+
push!(tutorial_menu, title => joinpath(pluto_relative_path, file * ".md"))
4970
end
5071

5172
DocMeta.setdocmeta!(GraphNeuralNetworks, :DocTestSetup,
5273
:(using GraphNeuralNetworks, Graphs, SparseArrays, NNlib, Flux);
5374
recursive=true)
5475

76+
prettyurls = get(ENV, "CI", nothing) == "true"
77+
mathengine = MathJax3()
78+
5579
makedocs(;
56-
modules=[GraphNeuralNetworks, NNlib, Flux, Graphs, SparseArrays],
57-
doctest=false, clean=true,
80+
modules = [GraphNeuralNetworks, NNlib, Flux, Graphs, SparseArrays],
81+
doctest = false,
82+
clean = true,
83+
format= Documenter.HTML(; mathengine, prettyurls),
5884
sitename = "GraphNeuralNetworks.jl",
5985
pages = ["Home" => "index.md",
6086
"Graphs" => "gnngraph.md",
6187
"Message Passing" => "messagepassing.md",
6288
"Model Building" => "models.md",
6389
"Datasets" => "datasets.md",
90+
"Tutorials" => tutorial_menu,
91+
# "Tutorials" =>
92+
# [
93+
# "Intro to Graph Neural Networks" => "gnn_intro_pluto.md",
94+
# "Graph Classification" => "graph_classification_pluto.md",
95+
# ],
6496
"API Reference" =>
6597
[
6698
"GNNGraph" => "api/gnngraph.md",

docs/src/datasets.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
GraphNeuralNetworks.jl doesn't come with its own datasets, but leverages those available in the Julia (and non-Julia) ecosystem. In particular, the [examples in the GraphNeuralNetworks.jl repository](https://github.com/CarloLucibello/GraphNeuralNetworks.jl/tree/master/examples) make use of the [MLDatasets.jl](https://github.com/JuliaML/MLDatasets.jl) package. There you will find common graph datasets such as Cora, PubMed, Citeseer, TUDataset and [many others](https://juliaml.github.io/MLDatasets.jl/dev/datasets/graphs/).
44

5-
GraphNeuralNetworks.jl provides the [`mldatasets2gnngraph`](@ref) method for interfacing with MLDatasets.jl.
5+
GraphNeuralNetworks.jl provides the [`mldataset2gnngraph`](@ref) method for interfacing with MLDatasets.jl.
66

77
```@docs
8-
mldatasets2gnngraph
8+
mldataset2gnngraph
99
```

docs/src/tutorials/gnn_intro.pluto.jl renamed to docs/src/tutorials/gnn_intro_pluto.jl

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,33 @@ begin
1414
import GraphMakie
1515
import CairoMakie as Makie
1616
using Graphs
17-
end
18-
19-
# ╔═╡ 5de79e7a-46e6-4cbc-9cf4-0e21823fd9ed
20-
## These Pluto noteboook is a julia adaptation of the
21-
## Pytorch Geometric tutorials that can be found at
22-
## https://pytorch-geometric.readthedocs.io/en/latest/notes/colabs.html
17+
using PlutoUI
18+
Random.seed!(17); # for reproducibility
19+
end;
2320

2421
# ╔═╡ 03a9e023-e682-4ea3-a10b-14c4d101b291
25-
2622
md"""
2723
# Introduction: Hands-on Graph Neural Networks
2824
25+
*This Pluto noteboook is a julia adaptation of the Pytorch Geometric tutorials that can be found [here](https://pytorch-geometric.readthedocs.io/en/latest/notes/colabs.html).*
26+
2927
Recently, deep learning on graphs has emerged to one of the hottest research fields in the deep learning community.
3028
Here, **Graph Neural Networks (GNNs)** aim to generalize classical deep learning concepts to irregular structured data (in contrast to images or texts) and to enable neural networks to reason about objects and their relations.
3129
3230
This is done by following a simple **neural message passing scheme**, where node features ``\mathbf{x}_i^{(\ell)}`` of all nodes ``i \in \mathcal{V}`` in a graph ``\mathcal{G} = (\mathcal{V}, \mathcal{E})`` are iteratively updated by aggregating localized information from their neighbors ``\mathcal{N}(i)``:
3331
3432
```math
35-
\mathbf{x}_i^{(\ell + 1)} = f^{(\ell + 1)}_{\theta} \left( \mathbf{x}_i^{(\ell)}, \left\{ \mathbf{x}_w^{(\ell)} : w \in \mathcal{N}(i) \right\} \right)
33+
\mathbf{x}_i^{(\ell + 1)} = f^{(\ell + 1)}_{\theta} \left( \mathbf{x}_i^{(\ell)}, \left\{ \mathbf{x}_j^{(\ell)} : j \in \mathcal{N}(i) \right\} \right)
3634
```
3735
3836
This tutorial will introduce you to some fundamental concepts regarding deep learning on graphs via Graph Neural Networks based on the **[GraphNeuralNetworks.jl library](https://github.com/CarloLucibello/GraphNeuralNetworks.jl)**.
3937
GNN.jl is an extension library to the popular deep learning framework [Flux.jl](https://fluxml.ai/Flux.jl/stable/), and consists of various methods and utilities to ease the implementation of Graph Neural Networks.
4038
39+
Let's first import the packages we need:
40+
"""
41+
42+
# ╔═╡ ef96f5ae-724d-4b8e-b7d7-c116ad1c3279
43+
md"""
4144
Following [Kipf et al. (2017)](https://arxiv.org/abs/1609.02907), let's dive into the world of GNNs by looking at a simple graph-structured example, the well-known [**Zachary's karate club network**](https://en.wikipedia.org/wiki/Zachary%27s_karate_club). This graph describes a social network of 34 members of a karate club and documents links between members who interacted outside the club. Here, we are interested in detecting communities that arise from the member's interaction.
4245
4346
GNN.jl provides utilities to convert [MLDatasets.jl](https://github.com/JuliaML/MLDatasets.jl)'s datasets to its own type:
@@ -88,7 +91,7 @@ Let's now look at the underlying graph in more detail:
8891
"""
8992

9093
# ╔═╡ a7ad9de3-3e18-4aff-b118-a4d798a2f4ec
91-
begin
94+
with_terminal() do
9295
# Gather some statistics about the graph.
9396
println("Number of nodes: $(g.num_nodes)")
9497
println("Number of edges: $(g.num_edges)")
@@ -139,13 +142,7 @@ Since a `GNNGraph` is an `AbstractGraph` from the `Graphs.jl` library, it suppor
139142
"""
140143

141144
# ╔═╡ 9820cc77-ae0a-454a-86b6-a23dbc56b6fd
142-
begin
143-
g2= rand_graph(g.num_nodes, 30, bidirected=false)
144-
GraphMakie.graphplot(Graph(g2), node_size=20, node_color=labels, arrow_show=false)
145-
end
146-
147-
# ╔═╡ cf428e12-17fc-46c9-b0ec-906a79f001cb
148-
?GraphMakie.graphplot
145+
GraphMakie.graphplot(g, node_size=20, node_color=labels)
149146

150147
# ╔═╡ 86135c51-950c-4c08-b9e0-6c892234ff87
151148
md"""
@@ -323,6 +320,7 @@ GraphNeuralNetworks = "cffab07f-9bc2-4db1-8861-388f63bf7694"
323320
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
324321
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
325322
MLDatasets = "eb30cadb-4394-5ae3-aed4-317e484a6458"
323+
PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
326324
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
327325
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
328326
@@ -333,6 +331,7 @@ GraphMakie = "~0.3.5"
333331
GraphNeuralNetworks = "~0.4.2"
334332
Graphs = "~1.7.0"
335333
MLDatasets = "~0.7.1"
334+
PlutoUI = "~0.7.39"
336335
"""
337336

338337
# ╔═╡ 00000000-0000-0000-0000-000000000002
@@ -348,6 +347,12 @@ git-tree-sha1 = "6f1d9bc1c08f9f4a8fa92e3ea3cb50153a1b40d4"
348347
uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c"
349348
version = "1.1.0"
350349
350+
[[deps.AbstractPlutoDingetjes]]
351+
deps = ["Pkg"]
352+
git-tree-sha1 = "8eaf9f1b4921132a4cff3f36a1d9ba923b14a481"
353+
uuid = "6e696c72-6542-2067-7265-42206c756150"
354+
version = "1.1.4"
355+
351356
[[deps.AbstractTrees]]
352357
git-tree-sha1 = "03e0550477d86222521d254b741d470ba17ea0b5"
353358
uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
@@ -931,6 +936,24 @@ git-tree-sha1 = "cb7099a0109939f16a4d3b572ba8396b1f6c7c31"
931936
uuid = "34004b35-14d8-5ef3-9330-4cdb6864b03a"
932937
version = "0.3.10"
933938
939+
[[deps.Hyperscript]]
940+
deps = ["Test"]
941+
git-tree-sha1 = "8d511d5b81240fc8e6802386302675bdf47737b9"
942+
uuid = "47d2ed2b-36de-50cf-bf87-49c2cf4b8b91"
943+
version = "0.0.4"
944+
945+
[[deps.HypertextLiteral]]
946+
deps = ["Tricks"]
947+
git-tree-sha1 = "c47c5fa4c5308f27ccaac35504858d8914e102f9"
948+
uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2"
949+
version = "0.9.4"
950+
951+
[[deps.IOCapture]]
952+
deps = ["Logging", "Random"]
953+
git-tree-sha1 = "f7be53659ab06ddc986428d3a9dcc95f6fa6705a"
954+
uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89"
955+
version = "0.2.2"
956+
934957
[[deps.IRTools]]
935958
deps = ["InteractiveUtils", "MacroTools", "Test"]
936959
git-tree-sha1 = "af14a478780ca78d5eb9908b263023096c2b9d64"
@@ -1505,6 +1528,12 @@ git-tree-sha1 = "bb16469fd5224100e422f0b027d26c5a25de1200"
15051528
uuid = "995b91a9-d308-5afd-9ec6-746e21dbc043"
15061529
version = "1.2.0"
15071530
1531+
[[deps.PlutoUI]]
1532+
deps = ["AbstractPlutoDingetjes", "Base64", "ColorTypes", "Dates", "Hyperscript", "HypertextLiteral", "IOCapture", "InteractiveUtils", "JSON", "Logging", "Markdown", "Random", "Reexport", "UUIDs"]
1533+
git-tree-sha1 = "8d1f54886b9037091edf146b517989fc4a09efec"
1534+
uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
1535+
version = "0.7.39"
1536+
15081537
[[deps.PolygonOps]]
15091538
git-tree-sha1 = "77b3d3605fc1cd0b42d95eba87dfcd2bf67d5ff6"
15101539
uuid = "647866c9-e3ac-4575-94e7-e3d426903924"
@@ -1837,6 +1866,11 @@ git-tree-sha1 = "c76399a3bbe6f5a88faa33c8f8a65aa631d95013"
18371866
uuid = "28d57a85-8fef-5791-bfe6-a80928e7c999"
18381867
version = "0.4.73"
18391868
1869+
[[deps.Tricks]]
1870+
git-tree-sha1 = "6bac775f2d42a611cdfcd1fb217ee719630c4175"
1871+
uuid = "410a4b4d-49e4-4fbc-ab6d-cb71b17b3775"
1872+
version = "0.1.6"
1873+
18401874
[[deps.TupleTools]]
18411875
git-tree-sha1 = "3c712976c47707ff893cf6ba4354aa14db1d8938"
18421876
uuid = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6"
@@ -2016,9 +2050,9 @@ version = "3.5.0+0"
20162050
"""
20172051

20182052
# ╔═╡ Cell order:
2019-
# ╠═361e0948-d91a-11ec-2d95-2db77435a0c1
2020-
# ╠═5de79e7a-46e6-4cbc-9cf4-0e21823fd9ed
20212053
# ╟─03a9e023-e682-4ea3-a10b-14c4d101b291
2054+
# ╠═361e0948-d91a-11ec-2d95-2db77435a0c1
2055+
# ╟─ef96f5ae-724d-4b8e-b7d7-c116ad1c3279
20222056
# ╠═4ba372d4-7a6a-41e0-92a0-9547a78e2898
20232057
# ╟─55aca2f0-4bbb-4d3a-9777-703896cfc548
20242058
# ╠═a1d35896-0f52-4c8b-b7dc-ec65649237c8
@@ -2031,7 +2065,6 @@ version = "3.5.0+0"
20312065
# ╠═d627736a-fd5a-4cdc-bd4e-89ff8b8c55bd
20322066
# ╟─98bb86d2-a7b9-4110-8851-8829a9f9b4d0
20332067
# ╠═9820cc77-ae0a-454a-86b6-a23dbc56b6fd
2034-
# ╠═cf428e12-17fc-46c9-b0ec-906a79f001cb
20352068
# ╟─86135c51-950c-4c08-b9e0-6c892234ff87
20362069
# ╠═88d1e59f-73d6-46ee-87e8-35beb7bc7674
20372070
# ╟─9838189c-5cf6-4f21-b58e-3bb905408ad3

0 commit comments

Comments
 (0)