cuvis_ai.pipeline.graph.Graph
- class cuvis_ai.pipeline.graph.Graph(name: str)[source]
Bases:
object
Main class for connecting nodes in a CUVIS.AI processing graph
Methods
__init__
(name)add_base_node
(node)Adds new node into the graph by creating the first entry point.
add_edge
(node, node2)Adds sequential nodes to create a directed edge.
add_node
(node[, parent])Add a new node into the graph structure
delete_node
(id)Removes a node from the graph.
fit
(X[, Y, M])forward
(X[, Y, M, backend])freeze
()load
(structure, data_dir)load_from_file
(filepath)Reconstruct the graph from a file path defining the location of a zip archive.
Iterate over all (pytorch-) parameters in all layers contained in the Graph.
save_to_file
(filepath)serialize
(data_dir)Convert graph structure and all contained nodes to a serializable YAML format.
train
(train_dl, test_dl)Attributes
Get a list with all pytorch layers in the Graph.
- add_base_node(node: Node) None [source]
Adds new node into the graph by creating the first entry point.
- Parameters:
node (Node) – CUVIS.AI node to add to the graph
- add_edge(node: Node, node2: Node) None [source]
Adds sequential nodes to create a directed edge. At least one of the nodes should already be in the graph.
- add_node(node: Node, parent: list[Node] | Node | None = None) None [source]
Add a new node into the graph structure
- Parameters:
- Raises:
ValueError – If no parent is provided, node is assumed to be the base node of the graph. This event will raise an error to prevent base from being overwritten.
ValueError – If parent(s) do not already belong to the graph.
ValueError – If parent(s) and child nodes are mismatched in expected data size.
- delete_node(id: Node | str) None [source]
Removes a node from the graph. To successfully remove a node, it must not have successors.
- Parameters:
id (Node | str) – UUID for target node to delete, or a copy of the node itself.
- Raises:
ValueError – Node to delete contains successors in the graph.
ValueError – Node does not exist in the graph.
- forward(X: ndarray, Y: ndarray | List | None = None, M: ndarray | List | None = None, backend: str = 'memory') tuple[ndarray, ndarray, ndarray] [source]
- classmethod load_from_file(filepath: str) None [source]
Reconstruct the graph from a file path defining the location of a zip archive.
- Parameters:
filepath (str) – Location of zip archive
- parameters() Iterator [source]
Iterate over all (pytorch-) parameters in all layers contained in the Graph.
- serialize(data_dir: Path) dict [source]
Convert graph structure and all contained nodes to a serializable YAML format. Numeric data and fit models will be stored in zipped directory named with current time.
- train(train_dl: DataLoader, test_dl: DataLoader)[source]