LeapGraph

code_loader.contract.visualizer_classes.LeapGraph

Used to visualize a 1D signal.

import numpy.typing as npt
from code_loader.contract.enums import LeapDataType

@dataclass
class LeapGraph:
    data: npt.NDArray[np.float32]
    type: LeapDataType = LeapDataType.Graph
    x_label: Optional[str] = None
    y_label: Optional[str] = None
    x_range: Optional[Tuple[float,float]] = None
Args

data

an np.ndarray float32 [N,1] array where N is the number of points in the graph.

x_label

(optional) - the x label for the graph

y_label

(optional) - the y label for the graph

x_range

(optional) - controlling the ticks on the x axis by supplying a minimum and maximum value

Examples

Basic Usage

from code_loader.contract.visualizer_classes import LeapGraph
from code_loader.contract.enums import LeapDataType
import numpy as np
...

@tensorleap_custom_visualizer("diff", LeapDataType.Graph)
def diff_per_channel_visualizer(prediction: np.ndarray, ground_truth: np.array) -> LeapGraph:
    diff = pred - ground_truth
    return LeapGraph(diff)

Last updated

Was this helpful?