gigl.transforms.utils#
Attributes#
Functions#
|
Helper function to add edge attributes to a HeteroData object. |
|
Helper function to add node attributes to a HeteroData object. |
Module Contents#
- gigl.transforms.utils.add_edge_attr(data, values, attr_name=None, edge_type_to_idx=None)[source]#
Helper function to add edge attributes to a HeteroData object.
- Parameters:
data (torch_geometric.data.HeteroData) – The HeteroData object to modify.
values (Union[torch.Tensor, Dict[EdgeType, torch.Tensor]]) –
Either: - A tensor of values in homogeneous edge order (requires edge_type_to_idx
or will be computed from data.edge_types), OR
A dictionary mapping edge types to tensors of values for each type.
attr_name (Optional[str]) – The name of the attribute to add. If None, concatenates to existing edge_attr attribute for each edge type (or creates it).
edge_type_to_idx (Optional[Dict[EdgeType, Tuple[int, int]]]) – Optional mapping from edge type to (start, end) indices. Only used when values is a tensor. If None, it will be computed from data.edge_types.
- Returns:
The modified HeteroData object.
- Return type:
torch_geometric.data.HeteroData
- gigl.transforms.utils.add_node_attr(data, values, attr_name=None, node_type_to_idx=None)[source]#
Helper function to add node attributes to a HeteroData object.
- Parameters:
data (torch_geometric.data.HeteroData) – The HeteroData object to modify.
values (Union[torch.Tensor, Dict[str, torch.Tensor]]) –
Either: - A tensor of values in homogeneous node order (requires node_type_to_idx
or will be computed from data.node_types), OR
A dictionary mapping node types to tensors of values for each type.
attr_name (Optional[str]) – The name of the attribute to add. If None, concatenates to existing x attribute for each node type (or creates it).
node_type_to_idx (Optional[Dict[str, Tuple[int, int]]]) – Optional mapping from node type to (start, end) indices. Only used when values is a tensor. If None, it will be computed from data.node_types.
- Returns:
The modified HeteroData object.
- Return type:
torch_geometric.data.HeteroData