or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

file-writer.mdglobal-writer.mdindex.mdrecord-writer.mdsummary-writer.mdtorchvis.mdutilities.md
tile.json

tessl/pypi-tensorboardx

TensorBoardX lets you watch Tensors Flow without Tensorflow

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/tensorboardx@2.6.x

To install, run

npx @tessl/cli install tessl/pypi-tensorboardx@2.6.0

index.mddocs/

TensorBoardX

TensorBoardX lets you watch Tensors Flow without TensorFlow. A Python library that provides TensorBoard event logging capabilities without requiring TensorFlow, enabling visualization of machine learning experiments through simple function calls. Supports comprehensive visualization types including scalars, images, figures, histograms, audio, text, computational graphs, ONNX graphs, embeddings, precision-recall curves, 3D meshes, hyperparameters, and videos.

Package Information

  • Package Name: tensorboardX
  • Language: Python
  • Installation: pip install tensorboardX
  • Optional Performance: pip install crc32c (for speed), pip install soundfile (for audio)

Core Imports

from tensorboardX import SummaryWriter

Multiple classes available:

from tensorboardX import (
    SummaryWriter,      # Main writer class
    FileWriter,         # Low-level protocol buffer writer
    GlobalSummaryWriter, # Thread-safe writer with auto-incrementing steps
    RecordWriter,       # Low-level TensorFlow record format writer
    TorchVis           # Multi-backend visualization (TensorBoard + Visdom)
)

Basic Usage

from tensorboardX import SummaryWriter
import numpy as np

# Create a SummaryWriter
writer = SummaryWriter('runs/experiment_1')

# Log scalar values
for step in range(100):
    loss = np.random.random()
    accuracy = np.random.random()
    
    writer.add_scalar('Loss/Train', loss, step)
    writer.add_scalar('Accuracy/Train', accuracy, step)

# Log images, histograms, and other data types
dummy_img = np.random.rand(3, 64, 64)  # CHW format
writer.add_image('Sample_Image', dummy_img, step)

# Close the writer
writer.close()

# View in TensorBoard
# tensorboard --logdir=runs

Architecture

TensorBoardX provides multiple writer classes with different capabilities:

  • SummaryWriter: High-level API for all visualization types with automatic event file management
  • FileWriter: Lower-level protocol buffer writer for direct event file control
  • GlobalSummaryWriter: Thread-safe writer with automatic step incrementing for concurrent environments
  • RecordWriter: Basic TensorFlow record format writer for custom event handling
  • TorchVis: Multi-backend wrapper supporting both TensorBoard and Visdom simultaneously

The library integrates seamlessly with PyTorch, NumPy, and other ML frameworks while maintaining compatibility with TensorBoard's visualization ecosystem.

Capabilities

Summary Writer

Main high-level writer class providing comprehensive logging capabilities for scalars, media, graphs, embeddings, and advanced visualizations with automatic file management and flexible configuration options.

class SummaryWriter:
    def __init__(
        self,
        logdir: Optional[str] = None,
        comment: Optional[str] = "",
        purge_step: Optional[int] = None,
        max_queue: Optional[int] = 10,
        flush_secs: Optional[int] = 120,
        filename_suffix: Optional[str] = '',
        write_to_disk: Optional[bool] = True,
        log_dir: Optional[str] = None,
        comet_config: Optional[dict] = {"disabled": True}
    ): ...
    
    def add_scalar(self, tag: str, scalar_value, global_step: Optional[int] = None, walltime: Optional[float] = None): ...
    def add_image(self, tag: str, img_tensor, global_step: Optional[int] = None, walltime: Optional[float] = None): ...
    def add_graph(self, model, input_to_model=None, verbose=False): ...
    def close(self): ...

Summary Writer

File Writer

Low-level protocol buffer writer for direct event file control, providing fine-grained management of TensorBoard event files with manual summary and event handling.

class FileWriter:
    def __init__(self, logdir: str, max_queue: int = 10, flush_secs: int = 120, filename_suffix: str = ''): ...
    
    def add_event(self, event, step=None, walltime=None): ...
    def add_summary(self, summary, global_step=None, walltime=None): ...
    def get_logdir(self) -> str: ...
    def flush(self): ...
    def close(self): ...

File Writer

Global Writer

Thread-safe writer with automatic step incrementing for concurrent logging across processes, simplifying multi-threaded experiment tracking without manual step management.

class GlobalSummaryWriter:
    def __init__(
        self,
        logdir: Optional[str] = None,
        comment: str = '',
        purge_step: Optional[int] = None,
        max_queue: int = 10,
        flush_secs: int = 120,
        filename_suffix: str = '',
        write_to_disk: bool = True,
        log_dir: Optional[str] = None,
        coalesce_process: bool = True
    ): ...
    
    def add_scalar(self, tag: str, scalar_value, walltime: Optional[float] = None): ...
    def add_image(self, tag: str, img_tensor, walltime: Optional[float] = None): ...
    @staticmethod
    def getSummaryWriter() -> 'GlobalSummaryWriter': ...

Global Writer

Multi-Backend Visualization

Multi-backend visualization class supporting both TensorBoard and Visdom simultaneously, enabling cross-platform experiment monitoring and visualization comparison.

class TorchVis:
    def __init__(self, *args, **init_kwargs): ...
    
    def register(self, *args, **init_kwargs): ...
    def unregister(self, *args): ...
    # All SummaryWriter methods available through dynamic proxy

Multi-Backend Visualization

Record Writer

Low-level TensorFlow record format writer for direct binary record writing with support for local filesystem, Amazon S3, and Google Cloud Storage backends.

class RecordWriter:
    def __init__(self, path: str): ...
    
    def write(self, data: bytes): ...
    def flush(self): ...
    def close(self): ...

Record Writer

Utility Functions

Data conversion and tensor processing utilities for preparing data for TensorBoard visualization, including format conversion, figure handling, and tensor manipulation.

def figure_to_image(figures, close: bool = True): ...
def make_np(x): ...
def convert_to_HWC(tensor, input_format: str): ...
def convert_to_NTCHW(tensor, input_format: str): ...

Utility Functions