RWSEEncoder
¶
Bases: Module
Projection of the random-walk structural encodings (RWSE) of the
nodes, as in the GPS example of PyG (examples/graph_gps.py) and the
RWSE node encoder of GraphGPS.
The encodings (e.g. computed by
AddRandomWalkPE) are normalized and
linearly projected:
The result is typically concatenated with an embedding of the node
features before a GPSConv.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pe_dim
|
int
|
Size of the input encodings (the walk length). |
required |
out_features_dim
|
int
|
Size of the projected encodings. |
required |
norm
|
Normalization of the input encodings: |
'batch'
|
Example:
import mlx.core as mx
from mlx_graphs.nn import RWSEEncoder
encoder = RWSEEncoder(pe_dim=20, out_features_dim=8)
random_walk_pe = mx.random.uniform(shape=(10, 20))
>>> encoder(random_walk_pe).shape
(10, 8)
References
Methods:
| Name | Description |
|---|---|
__call__ |
Projects the encodings |
Source code in mlx_graphs/nn/encoding.py
__call__
¶
__call__(pe: array, batch_indices: Optional[array] = None)
Projects the encodings pe of shape [num_nodes, pe_dim].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pe
|
array
|
Encodings of shape |
required |
batch_indices
|
Optional[array]
|
Unused, for compatibility with
|
None
|
Source code in mlx_graphs/nn/encoding.py
from mlx_graphs.nn import RWSEEncoder · mlx_graphs/nn/encoding.py