read_tensorboard_projector

read_tensorboard_projector(
    logdir
    *
    label=None
    coordinates=None
    max_points=DEFAULT_MAX_POINTS
)

Read the embeddings of a Projector log directory as 2D scatter plots.

Parameters

Name Type Description Default
logdir str or os.PathLike The directory holding projector_config.pbtxt, such as the log_dir of PyTorch’s SummaryWriter.add_embedding. required
label str The metadata column the points are grouped by. By default label when there is one, else the first column. None
coordinates numpy.ndarray Two coordinates per point to draw instead of the principal components, such as a t-SNE or UMAP projection computed elsewhere. Only for a directory holding one embedding. None
max_points int or None At most this many points per chart, evenly sampled, with a warning. 2000

Returns

Name Type Description
list of TensorBoardChart One per embedding, tagged with its tensor_name; runs names the label groups, in the order their layers are drawn.

Raises

Name Type Description
FileNotFoundError If logdir holds no projector_config.pbtxt.
ValueError If coordinates is not two per point, or the directory holds more than one embedding for it.

Notes

Each label group is one scatter layer, named in the legend, so a reader moves between classes with Page Up and Page Down and along one class’s points with the arrow keys. The axes are the first two principal components, each named with the share of the variance it explains.

Examples

>>> import maidr
>>> (chart,) = maidr.read_tensorboard_projector("runs/embeddings")
>>> maidr.show(chart)