shuffle_node
¶
shuffle_node(
node_features: array,
batch_indices: Optional[array] = None,
training: bool = True,
) -> tuple[array, array]
Randomly shuffles the rows of node_features, within each graph if
batch_indices is given.
Randomness comes from mx.random, so results are reproducible with
mx.random.seed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_features
|
array
|
The node features, of shape |
required |
batch_indices
|
Optional[array]
|
Optional graph of each node, of shape |
None
|
training
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
array
|
A tuple |
array
|
the permutation. |
Example:
node_features = mx.arange(6).reshape(6, 1)
batch_indices = mx.array([0, 0, 0, 1, 1, 1])
shuffle_node(node_features, batch_indices)
# e.g. (mx.array([[1], [2], [0], [5], [3], [4]]),
# mx.array([1, 2, 0, 5, 3, 4]))
Source code in mlx_graphs/utils/augmentation.py
from mlx_graphs.utils import shuffle_node · mlx_graphs/utils/augmentation.py