TensorBoardX lets you watch Tensors Flow without Tensorflow
Low-level TensorFlow record format writer for direct event file management. Provides basic binary record writing capabilities with support for local filesystem, Amazon S3, and Google Cloud Storage backends.
Creates a RecordWriter instance for writing binary protocol buffer records to various storage backends.
class RecordWriter:
def __init__(self, path: str):
"""
Creates a RecordWriter for writing TensorFlow record format files.
Parameters:
- path: File path for writing records. Supports local paths, S3 ("s3://bucket/path"),
and Google Cloud Storage ("gs://bucket/path") URLs.
"""Write binary data records with CRC32C checksums for data integrity verification.
def write(self, data: bytes):
"""
Write a binary data record with length header and CRC32C checksums.
Parameters:
- data: Binary data to write as a record
"""Control file flushing and closing for data persistence and resource cleanup.
def flush(self):
"""
Flush any buffered data to the underlying storage.
"""
def close(self):
"""
Close the record writer and release resources.
"""RecordWriter supports multiple storage backends through a plugin system:
Requires pip install boto3 for S3 functionality.
from tensorboardX import RecordWriter
# Write to S3 bucket
writer = RecordWriter("s3://my-bucket/tensorboard/events.out.tfevents")
writer.write(event_data)
writer.close()Requires pip install google-cloud-storage for GCS functionality.
from tensorboardX import RecordWriter
# Write to GCS bucket
writer = RecordWriter("gs://my-bucket/tensorboard/events.out.tfevents")
writer.write(event_data)
writer.close()from tensorboardX import RecordWriter
# Create writer for local file
writer = RecordWriter("./logs/events.out.tfevents")
# Write binary protocol buffer data
event_data = b"serialized_protocol_buffer_data"
writer.write(event_data)
# Ensure data is written to disk
writer.flush()
writer.close()from tensorboardX import RecordWriter
# Automatic resource cleanup
class RecordWriterContext:
def __init__(self, path):
self.writer = RecordWriter(path)
def __enter__(self):
return self.writer
def __exit__(self, exc_type, exc_val, exc_tb):
self.writer.close()
# Usage
with RecordWriterContext("./logs/events.out.tfevents") as writer:
writer.write(event_data)
# Automatically closed on exitUtility functions for TensorFlow-compatible name generation and validation.
def make_valid_tf_name(name: str) -> str:
"""
Convert arbitrary strings to valid TensorFlow operation names.
Parameters:
- name: Input name string
Returns:
- Valid TensorFlow operation name string
"""Functions for registering custom storage backends.
def register_writer_factory(prefix: str, factory):
"""
Register a custom writer factory for specific URL prefixes.
Parameters:
- prefix: URL prefix (e.g., "s3", "gs")
- factory: Factory object with open() and directory_check() methods
Raises:
- ValueError: If prefix contains ':'
"""
def directory_check(path: str):
"""
Initialize directory structure for the given path.
Parameters:
- path: Directory path to initialize
"""
def open_file(path: str):
"""
Open a writer for the specified path using registered factories.
Parameters:
- path: File path, supports custom prefixes
Returns:
- File writer object
"""Install with Tessl CLI
npx tessl i tessl/pypi-tensorboardx