Skip to content

Commit 5dc4cf6

Browse files
committed
Add EdgeConv docstring
1 parent bb9cb67 commit 5dc4cf6

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

GNNLux/src/layers/conv.jl

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,49 @@ function (l::CGConv)(g, x, e, ps, st)
517517
return GNNlib.cg_conv(m, g, x, e), st
518518
end
519519

520+
@doc raw"""
521+
EdgeConv(nn; aggr=max)
522+
523+
Edge convolutional layer from paper [Dynamic Graph CNN for Learning on Point Clouds](https://arxiv.org/abs/1801.07829).
524+
525+
Performs the operation
526+
```math
527+
\mathbf{x}_i' = \square_{j \in N(i)}\, nn([\mathbf{x}_i; \mathbf{x}_j - \mathbf{x}_i])
528+
```
529+
530+
where `nn` generally denotes a learnable function, e.g. a linear layer or a multi-layer perceptron.
531+
532+
# Arguments
533+
534+
- `nn`: A (possibly learnable) function.
535+
- `aggr`: Aggregation operator for the incoming messages (e.g. `+`, `*`, `max`, `min`, and `mean`).
536+
537+
# Examples:
538+
539+
```julia
540+
using GNNLux, Lux, Random
541+
542+
# initialize random number generator
543+
rng = Random.default_rng()
544+
545+
# create data
546+
s = [1,1,2,3]
547+
t = [2,3,1,1]
548+
in_channel = 3
549+
out_channel = 5
550+
g = GNNGraph(s, t)
551+
x = rand(rng, Float32, in_channel, g.num_nodes)
552+
553+
# create layer
554+
l = EdgeConv(Dense(2 * in_channel, out_channel), aggr = +)
555+
556+
# setup layer
557+
ps, st = LuxCore.setup(rng, l)
558+
559+
# forward pass
560+
y, st = l(g, x, ps, st)
561+
```
562+
"""
520563
@concrete struct EdgeConv <: GNNContainerLayer{(:nn,)}
521564
nn <: AbstractLuxLayer
522565
aggr

0 commit comments

Comments
 (0)