IndexToMask
¶
IndexToMask(
attrs: Optional[Union[str, list[str]]] = None,
sizes: Optional[Union[int, Sequence[int]]] = None,
replace: bool = False,
)
Bases: BaseTransform
Converts index attributes (named *_index, e.g. train_index)
to boolean mask attributes (named *_mask, e.g. train_mask).
Attributes containing edge_index are never converted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attrs
|
Optional[Union[str, list[str]]]
|
Name(s) of the index attributes to convert. Default: |
None
|
sizes
|
Optional[Union[int, Sequence[int]]]
|
Size of the masks, as one int for all the attributes or a list
with one int per attribute. Default: |
None
|
replace
|
bool
|
If |
False
|
Example:
graph = GraphData(
edge_index=mx.array([[0, 1, 2], [1, 2, 3]]),
node_features=mx.ones((4, 1)),
train_index=mx.array([0, 2]),
)
graph = IndexToMask()(graph)
graph.train_mask
# mx.array([True, False, True, False])
Methods:
| Name | Description |
|---|---|
process |
Adds the masks to |
Source code in mlx_graphs/transforms/masks.py
process
¶
Adds the masks to data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
GraphData
|
The graph to transform. |
required |
Returns:
| Type | Description |
|---|---|
GraphData
|
The graph with the mask attributes. |
Source code in mlx_graphs/transforms/masks.py
from mlx_graphs.transforms import IndexToMask · mlx_graphs/transforms/masks.py