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

Fixed a few typos in notebooks, docs and docstrings #205

Merged
merged 1 commit into from
Sep 18, 2022
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
4 changes: 2 additions & 2 deletions docs/src/gnngraph.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ g.edata.e
## Edge weights

It is common to denote scalar edge features as edge weights. The `GNNGraph` has specific support
for edge weights: they can be stored as part of internal representions of the graph (COO or adjacency matrix). Some graph convolutional layers, most notably the [`GCNConv`](@ref), can use the edge weights to perform weighted sums over the nodes' neighborhoods.
for edge weights: they can be stored as part of internal representations of the graph (COO or adjacency matrix). Some graph convolutional layers, most notably the [`GCNConv`](@ref), can use the edge weights to perform weighted sums over the nodes' neighborhoods.

```julia
julia> source = [1, 1, 2, 2, 3, 3];
Expand All @@ -143,7 +143,7 @@ julia> get_edge_weight(g)

## Batches and Subgraphs

Multiple `GNNGraph`s can be batched togheter into a single graph
Multiple `GNNGraph`s can be batched together into a single graph
that contains the total number of the original nodes
and where the original graphs are disjoint subgraphs.

Expand Down
2 changes: 1 addition & 1 deletion docs/src/messagepassing.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ manipulating arrays of size ``D_{node} \times num\_nodes`` and

[`propagate`](@ref) is composed of two steps, also available as two independent methods:

1. [`apply_edges`](@ref) materializes node features on edges and applyes the message function.
1. [`apply_edges`](@ref) materializes node features on edges and applies the message function.
2. [`aggregate_neighbors`](@ref) applies a reduction operator on the messages coming from the neighborhood of each node.

The whole propagation mechanism internally relies on the [`NNlib.gather`](@ref)
Expand Down
10 changes: 5 additions & 5 deletions docs/src/tutorials/gnn_intro_pluto.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ end;
md"""
# Introduction: Hands-on Graph Neural Networks

*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).*
*This Pluto notebook is a julia adaptation of the Pytorch Geometric tutorials that can be found [here](https://pytorch-geometric.readthedocs.io/en/latest/notes/colabs.html).*

Recently, deep learning on graphs has emerged to one of the hottest research fields in the deep learning community.
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.
Expand Down Expand Up @@ -135,7 +135,7 @@ The `g` object holds 3 attributes:
These attributes are `NamedTuples` that can store multiple feature arrays: we can access a specific set of features e.g. `x`, with `g.ndata.x`.


In our task, `g.ndata.train_mask` describes for which nodes we already know their community assigments. In total, we are only aware of the ground-truth labels of 4 nodes (one for each community), and the task is to infer the community assignment for the remaining nodes.
In our task, `g.ndata.train_mask` describes for which nodes we already know their community assignments. In total, we are only aware of the ground-truth labels of 4 nodes (one for each community), and the task is to infer the community assignment for the remaining nodes.

The `g` object also provides some **utility functions** to infer some basic properties of the underlying graph.
For example, we can easily infer whether there exists isolated nodes in the graph (*i.e.* there exists no edge to any node), whether the graph contains self-loops (*i.e.*, ``(v, v) \in \mathcal{E}``), or whether the graph is bidirected (*i.e.*, for each edge ``(v, w) \in \mathcal{E}`` there also exists the edge ``(w, v) \in \mathcal{E}``).
Expand Down Expand Up @@ -262,13 +262,13 @@ This leads to the conclusion that GNNs introduce a strong inductive bias, leadin

But can we do better? Let's look at an example on how to train our network parameters based on the knowledge of the community assignments of 4 nodes in the graph (one for each community):

Since everything in our model is differentiable and parameterized, we can add some labels, train the model and observse how the embeddings react.
Since everything in our model is differentiable and parameterized, we can add some labels, train the model and observe how the embeddings react.
Here, we make use of a semi-supervised or transductive learning procedure: We simply train against one node per class, but are allowed to make use of the complete input graph data.

Training our model is very similar to any other Flux model.
In addition to defining our network architecture, we define a loss criterion (here, `logitcrossentropy` and initialize a stochastic gradient optimizer (here, `Adam`).
After that, we perform multiple rounds of optimization, where each round consists of a forward and backward pass to compute the gradients of our model parameters w.r.t. to the loss derived from the forward pass.
If you are not new to Flux, this scheme should appear familar to you.
If you are not new to Flux, this scheme should appear familiar to you.

Note that our semi-supervised learning scenario is achieved by the following line:
```
Expand All @@ -277,7 +277,7 @@ loss = logitcrossentropy(ŷ[:,train_mask], y[:,train_mask])
While we compute node embeddings for all of our nodes, we **only make use of the training nodes for computing the loss**.
Here, this is implemented by filtering the output of the classifier `out` and ground-truth labels `data.y` to only contain the nodes in the `train_mask`.

Let us now start training and see how our node embeddings evolve over time (best experienced by explicitely running the code):
Let us now start training and see how our node embeddings evolve over time (best experienced by explicitly running the code):
"""


Expand Down
6 changes: 3 additions & 3 deletions docs/src/tutorials/graph_classification_pluto.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ end;
md"""
# Graph Classification with Graph Neural Networks

*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).*
*This Pluto notebook is a julia adaptation of the Pytorch Geometric tutorials that can be found [here](https://pytorch-geometric.readthedocs.io/en/latest/notes/colabs.html).*

In this tutorial session we will have a closer look at how to apply **Graph Neural Networks (GNNs) to the task of graph classification**.
Graph classification refers to the problem of classifiying entire graphs (in contrast to nodes), given a **dataset of graphs**, based on some structural graph properties.
Graph classification refers to the problem of classifying entire graphs (in contrast to nodes), given a **dataset of graphs**, based on some structural graph properties.
Here, we want to embed entire graphs, and we want to embed those graphs in such a way so that they are linearly separable given a task at hand.


Expand Down Expand Up @@ -242,7 +242,7 @@ end
# ╔═╡ 3454b311-9545-411d-b47a-b43724b84c36
md"""
As one can see, our model reaches around **74% test accuracy**.
Reasons for the fluctations in accuracy can be explained by the rather small dataset (only 38 test graphs), and usually disappear once one applies GNNs to larger datasets.
Reasons for the fluctuations in accuracy can be explained by the rather small dataset (only 38 test graphs), and usually disappear once one applies GNNs to larger datasets.

## (Optional) Exercise

Expand Down
2 changes: 1 addition & 1 deletion src/mldatasets.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# We load a Graph Dataset from MLDatasets without explicitely depending on it
# We load a Graph Dataset from MLDatasets without explicitly depending on it

"""
mldataset2gnngraph(dataset)
Expand Down
2 changes: 1 addition & 1 deletion src/msgpass.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ end
"""
w_mul_xj(xi, xj, w) = reshape(w, (...)) .* xj

Similar to [`e_mul_xj`](@ref) but specialized on scalar edge feautures (weights).
Similar to [`e_mul_xj`](@ref) but specialized on scalar edge features (weights).
"""
w_mul_xj(xi, xj::AbstractArray, w::Nothing) = xj # same as copy_xj if no weights

Expand Down