hoops_ai.storage.MLStorage
- class hoops_ai.storage.MLStorage
Bases:
ABC- abstract append_edata(edge_features, feature_name, torch_type=torch.float)
Appends an edge feature to the 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 the graph’s edge data.
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.
- Return type:
None
- abstract append_extra_data(extra_data, feature_name, torch_type=torch.float)
Appends extra data to the graph’s internal 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 the internal 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.
- Return type:
None
- abstract append_ndata(node_features, feature_name, torch_type=torch.float)
Appends a node feature to the 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 the graph’s node data.
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.
- Return type:
None
- abstract 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.
- abstract load_graph(filepath)
Loads a graph from the specified filepath.
- Parameters:
filepath (str) – Path to load the graph from.
- Returns:
The loaded graph object.
- Return type:
Any
- Raises:
ValueError – If the graph cannot be loaded.
- abstract save_graph(filepath)
Saves the graph to the specified filepath.
- Parameters:
filepath (str) – Path to save the graph.
- Raises:
ValueError – If the graph has not been initialized.
- Return type:
- abstract setup_graph(source_nodes, target_nodes, num_nodes)
Creates a 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.
- Return type:
None