dropout_path
¶
dropout_path(
edge_index: array,
p: float = 0.2,
walks_per_node: int = 1,
walk_length: int = 3,
num_nodes: Optional[int] = None,
is_sorted: bool = False,
training: bool = True,
) -> tuple[array, array]
Drops edges along random walks ("MaskGAE: Masked Graph Modeling Meets Graph Autoencoders").
Each edge is sampled with probability p. From the source of every
sampled edge, walks_per_node uniform random walks of walk_length
steps are run, and every edge traversed by a walk is dropped (with all its
duplicates).
Randomness comes from mx.random, so results are reproducible with
mx.random.seed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_index
|
array
|
a [2, num_edges] array representing the source and target nodes of each edge |
required |
p
|
float
|
Probability of sampling each edge as the start of the walks.
Default: |
0.2
|
walks_per_node
|
int
|
Number of walks started from each sampled edge.
Default: |
1
|
walk_length
|
int
|
Number of steps of each walk. Default: |
3
|
num_nodes
|
Optional[int]
|
Number of nodes in the graph. Inferred from |
None
|
is_sorted
|
bool
|
If |
False
|
training
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
array
|
A tuple |
array
|
mask of shape |
Example:
edge_index = mx.array([[0, 1, 1, 2, 2, 3], [1, 0, 2, 1, 3, 2]])
edge_index, edge_mask = dropout_path(edge_index)
# edge_index: e.g. mx.array([[0, 1, 2, 2], [1, 2, 1, 3]])
# edge_mask: e.g. mx.array([True, False, True, True, True, False])
Source code in mlx_graphs/utils/dropout.py
from mlx_graphs.utils import dropout_path · mlx_graphs/utils/dropout.py