MaskToIndex
¶
Bases: BaseTransform
Converts boolean mask attributes (named *_mask, e.g.
train_mask) to index attributes (named *_index, e.g.
train_index).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attrs
|
Optional[Union[str, list[str]]]
|
Name(s) of the mask attributes to convert. Default: |
None
|
replace
|
bool
|
If |
False
|
Example:
graph = GraphData(
edge_index=mx.array([[0, 1, 2], [1, 2, 3]]),
train_mask=mx.array([True, False, True, False]),
)
graph = MaskToIndex()(graph)
graph.train_index
# mx.array([0, 2])
Methods:
| Name | Description |
|---|---|
process |
Adds the indices to |
Source code in mlx_graphs/transforms/masks.py
process
¶
Adds the indices to data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
GraphData
|
The graph to transform. |
required |
Returns:
| Type | Description |
|---|---|
GraphData
|
The graph with the index attributes. |
Source code in mlx_graphs/transforms/masks.py
from mlx_graphs.transforms import MaskToIndex · mlx_graphs/transforms/masks.py