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

__init__(name: str) None[source]

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

custom_copy()

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.

parameters()

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

torch_layers

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.

Parameters:
  • node (Node) – Parent node.

  • node2 (Node) – Child node.

add_node(node: Node, parent: list[Node] | Node | None = None) None[source]

Add a new node into the graph structure

Parameters:
  • node (Node) – CUVIS.AI type node

  • parent (list[Node] | Node, optional) – Node(s) that the child node should be connected to, with data flowing from parent(s) to child, by default None.

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.

custom_copy()[source]
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.

fit(X: ndarray, Y: ndarray | List | None = None, M: ndarray | List | None = None)[source]
forward(X: ndarray, Y: ndarray | List | None = None, M: ndarray | List | None = None, backend: str = 'memory') tuple[ndarray, ndarray, ndarray][source]
freeze()[source]
load(structure: dict, data_dir: Path) None[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.

save_to_file(filepath) None[source]
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.

property torch_layers: List[Module]

Get a list with all pytorch layers in the Graph.

train(train_dl: DataLoader, test_dl: DataLoader)[source]