APPNP
¶
Bases: MessagePassing
Approximate personalized propagation of neural predictions layer from "Predict then Propagate: Graph Neural Networks meet Personalized PageRank" paper.
where \(\mathbf{\hat{A}} = \mathbf{A} + \mathbf{I}\) is the (weighted) adjacency matrix with self-loops and \(\mathbf{\hat{D}}\) its diagonal degree matrix.
The layer has no parameters. It is usually applied to the output of an MLP.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
K
|
int
|
Number of propagation steps |
required |
alpha
|
float
|
Teleport probability \(\alpha\) |
required |
dropout
|
float
|
Probability to drop each edge of the normalized adjacency matrix. A new set of edges is dropped at every propagation step, and only in training mode. |
0.0
|
add_self_loops
|
bool
|
Whether to add a self-loop to every node that has none |
True
|
**kwargs
|
Arguments of |
{}
|
Example:
import mlx.core as mx
import mlx.nn as nn
from mlx_graphs.nn import APPNP
edge_index = mx.array([[0, 1, 2, 3, 4], [0, 0, 1, 1, 3]])
node_features = mx.ones((5, 16))
mlp = nn.Linear(16, 32)
prop = APPNP(K=10, alpha=0.1)
h = prop(edge_index, mlp(node_features))
>>> h.shape
(5, 32)
Methods:
| Name | Description |
|---|---|
__call__ |
Computes the forward pass of APPNP. |
Source code in mlx_graphs/nn/conv/appnp.py
__call__
¶
__call__(
edge_index: array,
node_features: array,
edge_weights: Optional[array] = None,
) -> array
Computes the forward pass of APPNP.
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 propagated node features, same shape as |
Source code in mlx_graphs/nn/conv/appnp.py
from mlx_graphs.nn import APPNP · mlx_graphs/nn/conv/appnp.py