PANConv
¶
Bases: Module
The path integral based convolutional operator from the "Path Integral Based Convolution and Pooling for Graph Neural Networks" paper.
where \(\mathbf{M}\) denotes the normalized and learned maximal
entropy transition (MET) matrix that includes neighbors up to
filter_size hops:
As in PyG, the weight of \(\mathbf{A}^n\) is the product of the learned weights \(w_0 \cdots w_n\) (all initialized to 0.5), and \(\mathbf{Z}\) holds the number of non-zero entries of each row.
The layer also returns \(\mathbf{M}\) (in COO form, row
\(i\) gathering from column \(j\)), which
PANPooling takes as input.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_features_dim
|
int
|
Size of the input node features. |
required |
out_features_dim
|
int
|
Size of the output node features. |
required |
filter_size
|
int
|
The number of hops \(L\). |
required |
Example:
import mlx.core as mx
from mlx_graphs.nn import PANConv
conv = PANConv(16, 32, filter_size=2)
edge_index = mx.array([[0, 1, 1, 2], [1, 0, 2, 1]])
node_features = mx.random.normal((3, 16))
h, (m_index, m_weights) = conv(edge_index, node_features)
>>> h.shape
(3, 32)
Methods:
| Name | Description |
|---|---|
panentropy |
The un-normalized MET matrix $\sum_n (w_0 \cdots w_n) |
__call__ |
Computes the node embeddings. |
Source code in mlx_graphs/nn/conv/pan_conv.py
panentropy
¶
The un-normalized MET matrix \(\sum_n (w_0 \cdots w_n)
\mathbf{A}^n\), coalesced, where \(\mathbf{A}_{i, j}\) counts
the edges from node j to node i.
Source code in mlx_graphs/nn/conv/pan_conv.py
__call__
¶
Computes the node embeddings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_index
|
array
|
Edges of shape |
required |
node_features
|
array
|
Node features of shape |
required |
Returns:
| Type | Description |
|---|---|
array
|
A tuple |
Tuple[array, array]
|
embeddings and the MET matrix \(\mathbf{M}\) in COO form. |
Source code in mlx_graphs/nn/conv/pan_conv.py
from mlx_graphs.nn import PANConv · mlx_graphs/nn/conv/pan_conv.py