cuvis_ai.pipeline.executor.MemoryExecutor

class cuvis_ai.pipeline.executor.MemoryExecutor(graph: DiGraph, nodes: dict[str, Node], entry_point: str)[source]

Bases: object

__init__(graph: DiGraph, nodes: dict[str, Node], entry_point: str)[source]

Methods

__init__(graph, nodes, entry_point)

fit(X[, Y, M, warm_start])

Take a graph of uninitialized nodes and fit then given a set of inputs and outputs

fit_node(node, data, labels, metadata[, ...])

Private function wrapper to call the fit function for an individual node

forward(X[, Y, M])

Pass data through the graph by starting at the root node and flowing through all intermediary stages.

forward_node(node, data, labels, metadata)

Pass data through a node which has already been trained/fit.

train(train_dataloader, test_dataloader)

Train a graph use a dataloader to iteratively pass data through the graph

fit(X: ndarray, Y: ndarray | List | None = None, M: ndarray | List | None = None, warm_start=False)[source]

Take a graph of uninitialized nodes and fit then given a set of inputs and outputs

Parameters:
  • X (np.ndarray) – Input data

  • Y (Optional[Union[np.ndarray, List]], optional) – Input labels, by default None

  • M (Optional[Union[np.ndarray, List]], optional) – Input metadata, by default None

fit_node(node: Node, data: ndarray, labels: ndarray, metadata: ndarray, warm_start=False) ndarray[source]

Private function wrapper to call the fit function for an individual node

Parameters:
  • node (Node) – Graph node that will be fit

  • data (np.ndarray) – Training data

  • labels (np.ndarray) – Training labels

  • metadata (np.ndarray) – Training metadata

Returns:

Results of passing data through the fit node

Return type:

np.ndarray

Raises:

RuntimeError – Data is empty (length 0)

forward(X: ndarray, Y: ndarray | List | None = None, M: ndarray | List | None = None) tuple[ndarray, ndarray, ndarray][source]

Pass data through the graph by starting at the root node and flowing through all intermediary stages.

Parameters:
  • X (np.ndarray) – Input data

  • Y (Optional[Union[np.ndarray, List]], optional) – Label data

  • M (Optional[Union[np.ndarray, List]], optional) – Metadata by default None

Returns:

Residuals of processed X, Y, and M

Return type:

tuple[np.ndarray, np.ndarray, np.ndarray]

forward_node(node: Node, data: ndarray, labels: ndarray, metadata: ndarray) tuple[ndarray, ndarray, ndarray][source]

Pass data through a node which has already been trained/fit.

Parameters:
  • node (Node) – Node within the graph

  • data (np.ndarray) – Data to pass through the nodes

  • labels (np.ndarray) – Labels associated with input data

  • metadata (np.ndarray) – Metadata needed for forward pass

Returns:

Output data, output labels, output metadata

Return type:

tuple[np.ndarray, np.ndarray, np.ndarray]

train(train_dataloader: DataLoader, test_dataloader: DataLoader)[source]

Train a graph use a dataloader to iteratively pass data through the graph

Parameters:
Raises:

TypeError – Raises error if dataloaders passed to train function are not pytorch dataloaders