mask_feature
¶
mask_feature(
node_features: array,
p: float = 0.5,
mode: Literal["row", "col", "all"] = "col",
fill_value: float = 0.0,
training: bool = True,
) -> tuple[array, array]
Randomly masks the features of node_features with probability p,
replacing them with fill_value.
Randomness comes from mx.random, so results are reproducible with
mx.random.seed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_features
|
array
|
The features, of shape |
required |
p
|
float
|
Masking probability. Default: |
0.5
|
mode
|
Literal['row', 'col', 'all']
|
|
'col'
|
fill_value
|
float
|
Value of the masked entries. Default: |
0.0
|
training
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
array
|
A tuple |
array
|
the boolean mask of the kept entries, of shape |
tuple[array, array]
|
( |
tuple[array, array]
|
|
Example:
node_features = mx.ones((3, 4))
node_features, feature_mask = mask_feature(node_features, p=0.5)
# node_features: e.g. mx.array([[1, 0, 1, 0], [1, 0, 1, 0], [1, 0, 1, 0]])
# feature_mask: e.g. mx.array([[True, False, True, False]])
Source code in mlx_graphs/utils/augmentation.py
from mlx_graphs.utils import mask_feature · mlx_graphs/utils/augmentation.py