hoops_ai.storage.DGLGraphStoreHandler
- class hoops_ai.storage.DGLGraphStoreHandler
Bases:
MLStorage- append_edata(edge_features, feature_name, torch_type=torch.float)
Appends an edge feature to the DGL graph.
- Parameters:
edge_features (np.ndarray) – The edge feature data as a NumPy array.
feature_name (str) – The name to assign to the feature in dgl_graph.edata.
torch_type (torch.dtype, optional) – The PyTorch data type for the tensor. Defaults to torch.float.
- Raises:
ValueError – If the graph has not been initialized.
TypeError – If edge_features is not a numpy.ndarray.
- append_extra_data(extra_data, feature_name, torch_type=torch.float)
Appends extra data to the dgl_dictionary.
- Parameters:
extra_data (np.ndarray) – The extra feature data as a NumPy array.
feature_name (str) – The name to assign to the feature in dgl_dictionary.
torch_type (torch.dtype, optional) – The PyTorch data type for the tensor. Defaults to torch.float.
- Raises:
TypeError – If extra_data is not a numpy.ndarray.
- append_ndata(node_features, feature_name, torch_type=torch.float)
Appends a node feature to the DGL graph.
- Parameters:
node_features (np.ndarray) – The node feature data as a NumPy array.
feature_name (str) – The name to assign to the feature in dgl_graph.ndata.
torch_type (torch.dtype, optional) – The PyTorch data type for the tensor. Defaults to torch.float.
- Raises:
ValueError – If the graph has not been initialized.
TypeError – If node_features is not a numpy.ndarray.
- concatenate_data(target_dgl_tensor, source_dgl_tensor)
Concatenates the source_dgl_tensor to the target_dgl_tensor along the last dimension.
- Parameters:
target_dgl_tensor (torch.Tensor) – The tensor to append to.
source_dgl_tensor (torch.Tensor) – The tensor to append from.
- Returns:
The concatenated tensor.
- Return type:
- Raises:
TypeError – If either target_dgl_tensor or source_dgl_tensor is not a torch.Tensor.
- load_graph(filepath)
Loads a DGL graph from the specified filepath.
- Parameters:
filepath (str) – Path to load the DGL graph from.
- save_graph(filepath)
Saves the DGL graph to the specified filepath.
- Parameters:
filepath (str) – Path to save the DGL graph.
- setup_graph(source_nodes, target_nodes, num_nodes)
Creates a DGL graph using separate lists of source and target nodes and the total number of nodes.
- Parameters:
- Raises:
ValueError – If source_nodes and target_nodes do not have the same length.