LGConv
¶
LGConv(normalize: bool = True, **kwargs)
Bases: MessagePassing
Light graph convolution from the "LightGCN: Simplifying and Powering Graph Convolution Network for Recommendation" paper.
where \(e_{j,i}\) is the weight of the edge from node \(j\) to node \(i\) (1 if no weights are given). The layer has no parameters and does not add self-loops.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
normalize
|
bool
|
Whether to apply the symmetric degree normalization.
Default: |
True
|
**kwargs
|
Arguments of |
{}
|
Example:
import mlx.core as mx
from mlx_graphs.nn import LGConv
edge_index = mx.array([[0, 1, 2, 3, 4], [1, 0, 3, 2, 0]])
node_features = mx.random.normal((5, 16))
conv = LGConv()
h = conv(edge_index, node_features)
>>> h.shape
(5, 16)
References
[1] He et al. LightGCN: Simplifying and Powering Graph Convolution Network for Recommendation.
Methods:
| Name | Description |
|---|---|
__call__ |
Computes the forward pass of LGConv. |
Source code in mlx_graphs/nn/conv/lg_conv.py
__call__
¶
__call__(
edge_index: array,
node_features: array,
edge_weights: Optional[array] = None,
) -> array
Computes the forward pass of LGConv.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_index
|
array
|
Input edge index of shape |
required |
node_features
|
array
|
Input node features |
required |
edge_weights
|
Optional[array]
|
Optional scalar weight per edge, of shape |
None
|
Returns:
| Type | Description |
|---|---|
array
|
The computed node embeddings |
Source code in mlx_graphs/nn/conv/lg_conv.py
from mlx_graphs.nn import LGConv · mlx_graphs/nn/conv/lg_conv.py