Plot
tt.plot contains lightweight plotting helpers used for experiments. They are convenience utilities rather than the
core traceTorch API.
- tracetorch.plot.spike_train(list_of_tensors, spacing: float = 1.0, linelength: float = 0.8, linewidth: float = 0.5, title: str = 'Spike Train Raster', use_imshow: bool = True)[source]
Plot a spike train or signed activity sequence.
- Parameters:
list_of_tensors (Sequence[torch.Tensor]) – sequence of tensors, one per timestep. Each tensor is flattened as neuron/activity values.
spacing (float, default=1.0) – vertical spacing for event-plot mode.
linelength (float, default=0.8) – line length for event-plot mode.
linewidth (float, default=0.5) – line width for event-plot mode.
title (str, default="Spike Train Raster") – plot title.
use_imshow (bool, default=True) – if True, draw a signed heatmap. If False, draw an event plot of nonzero entries.
Notes
This helper is intended for quick experiment visualization. It calls
plt.show()and does not return the figure.
- tracetorch.plot.line_graph(list_of_values, title: str, label=None) None[source]
Plot a simple line graph from scalar values or tensors.
- Parameters:
list_of_values – sequence of Python scalars or tensors. Tensor values are stacked over time and each flattened element is plotted as its own line.
title (str) – plot title.
label (Sequence, optional) – labels for tensor-valued lines.
Notes
This helper is intended for quick experiment visualization. It calls
plt.show()and does not return the figure.
- tracetorch.plot.render_image(tensor: torch.Tensor, title: str = None, name: str = '', save: bool = False)[source]
Render a batch of grayscale or RGB images with Matplotlib.
- Parameters:
tensor (torch.Tensor) – image batch of shape
[B, C, H, W].Cmust be1or3.title (str, optional) – optional figure title.
name (str, default="") – filename stem used when
save=True.save (bool, default=False) – if True, save the figure to
media/{name}.png.
Notes
This helper is intended for quick experiment visualization. It calls
plt.show()and does not return the figure.
- tracetorch.plot.distributions(layers: List[torch.Tensor], title: str, *, n_grid: int = 1024, n_percentiles: int = 100, bandwidths: List[float | None] | None = None, show_percentile_lines: bool = False, compute_metrics: bool = True, max_kde_samples: int = 20000) Dict[str, Any][source]
Estimate and plot value distributions for tensors.
- Parameters:
layers (List[torch.Tensor]) – tensors to flatten and compare.
title (str) – plot title.
n_grid (int, default=1024) – number of KDE evaluation points.
n_percentiles (int, default=100) – number of percentile buckets.
bandwidths (List[Optional[float]], optional) – per-layer KDE bandwidths.
Noneentries use Silverman’s rule.show_percentile_lines (bool, default=False) – if True, show selected percentile markers.
compute_metrics (bool, default=True) – if True, compute pairwise KDE L1 distance and Wasserstein distance when SciPy is available.
max_kde_samples (int, default=20000) – maximum samples per tensor used for KDE evaluation.
- Returns:
plotting data including
grid,kdes,percentiles,stats,fig_ax, and optionalmetrics.- Return type:
Dict[str, Any]
Notes
This helper is intended for exploratory analysis and calls
plt.show().
- class tracetorch.plot.MeasurementManager(title: str, decay: list = [0.0, 0.9, 0.99, 0.999])[source]
Track and plot exponentially smoothed measurements.
MeasurementManagerstores raw scalar measurements and several exponential moving averages with different decays. It is useful for quick experiment tracking of losses, accuracies, or other scalar diagnostics.- Parameters:
title (str) – default plot title.
decay (list, default=[0., 0.9, 0.99, 0.999]) – EMA decay values to track.