@@ -20,13 +20,15 @@ In GraphNeuralNetworks.jl, the function [`propagate`](@ref) takes care of materi
20
20
node features on each edge, applying the message function, performing the
21
21
aggregation, and returning `` \bar{\mathbf{m}} `` .
22
22
It is then left to the user to perform further node and edge updates,
23
- manypulating arrays of size `` D_{node} \times num\_nodes `` and
23
+ manipulating arrays of size `` D_{node} \times num\_nodes `` and
24
24
`` D_{edge} \times num\_edges `` .
25
25
26
- As part of the [ ` propagate ` ] ( @ref ) pipeline, we have the function
27
- [ ` apply_edges ` ] ( @ref ) . It can be independently used to materialize
28
- node features on edges and perform edge-related computation without
29
- the following neighborhood aggregation one finds in ` propagate ` .
26
+ [ ` propagate ` ] ( @ref ) is composed of two steps corresponding to two
27
+ exported methods:
28
+ 1 . [ ` apply_edges ` ] ( @ref ) materializes node features on edges and
29
+ performs edge-related computation without.
30
+ 2 . [ ` aggregate_neighbors ` ] ( @ref ) applies a reduction operator on the messages coming
31
+ from the neighborhood of each node.
30
32
31
33
The whole propagation mechanism internally relies on the [ ` NNlib.gather ` ] ( @ref )
32
34
and [ ` NNlib.scatter ` ] ( @ref ) methods.
@@ -46,17 +48,11 @@ GNNGraph:
46
48
num_nodes = 10
47
49
num_edges = 20
48
50
51
+ julia> x = ones (2 ,10 );
49
52
50
- julia> x = ones (2 ,10 )
51
- 2 × 10 Matrix{Float64}:
52
- 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
53
- 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
54
-
55
- julia> z = 2 ones (2 ,10 )
56
- 2 × 10 Matrix{Float64}:
57
- 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0
58
- 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0
53
+ julia> z = 2 ones (2 ,10 );
59
54
55
+ # Return an edge features arrays (D × num_edges)
60
56
julia> apply_edges ((xi, xj, e) -> xi .+ xj, g, xi= x, xj= z)
61
57
2 × 20 Matrix{Float64}:
62
58
3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0 3.0
@@ -72,14 +68,16 @@ julia> apply_edges((xi, xj, e) -> xi.a + xi.b .* xj, g, xi=(a=x,b=z), xj=z)
72
68
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
73
69
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
74
70
```
71
+
75
72
The function [ ` propagate ` ] ( @ref ) instead performs the [ ` apply_edges ` ] ( @ref ) operation
76
- but then also applies a reduction over each node's neighborhood.
73
+ but then also applies a reduction over each node's neighborhood (see [ ` aggregate_neighbors ` ] ( @ref ) ) .
77
74
``` julia
78
75
julia> propagate ((xi, xj, e) -> xi .+ xj, g, + , xi= x, xj= z)
79
76
2 × 10 Matrix{Float64}:
80
77
3.0 6.0 9.0 9.0 0.0 6.0 6.0 3.0 15.0 3.0
81
78
3.0 6.0 9.0 9.0 0.0 6.0 6.0 3.0 15.0 3.0
82
79
80
+ # Previous output can be understood by looking at the degree
83
81
julia> degree (g)
84
82
10 - element Vector{Int64}:
85
83
1
0 commit comments