tbparse
tbparse is a Python library that allows users to load TensorBoard event logs directly into pandas DataFrames. It provides an easy way to read, parse, and plot TensorBoard data, simplifying analysis for machine learning experiments. The current version is 0.0.9, and the library maintains an active release cadence with frequent updates and bug fixes.
Common errors
-
ModuleNotFoundError: No module named 'pandas'
cause The `pandas` library, which `tbparse` relies on for DataFrame operations, is not installed in your environment.fixInstall `pandas` using `pip install pandas`. -
FileNotFoundError: [Errno 2] No such file or directory: 'path/to/your/log_dir'
cause The specified log directory for `SummaryReader` does not exist or is inaccessible. This could also mean the directory is empty or does not contain valid TensorBoard event files.fixVerify that the path to your TensorBoard log directory is correct and that it contains `.tfevents` files generated by TensorBoard. Ensure `SummaryReader` points to the *parent* directory containing the run subdirectories, or directly to a run directory. -
tensorflow.errors.NotFoundError: No OpKernel was registered to support Op 'DecodePng'
cause This error typically occurs when trying to parse image or audio events without the `tensorflow` library installed, or with a `tensorflow` version mismatch that prevents the necessary operations.fixInstall `tensorflow` in your environment (`pip install tensorflow`). Ensure it's a compatible version with your Python setup. `tbparse` v0.0.9 includes some parsing without `tensorflow`, but for full coverage, it's often needed. -
TypeError: 'event_types' parameter changed its behavior. Please check the documentation.
cause You are likely using `tbparse` v0.0.7 or newer, and your code is still relying on the deprecated behavior of the `event_types` parameter in `SummaryReader`.fixConsult the `tbparse` documentation for `SummaryReader` to understand the updated `event_types` parameter behavior and adjust your code accordingly. You might need to refine your filtering logic.
Warnings
- breaking Python 3.7 support has been dropped starting from `tbparse` v0.0.9. Users on Python 3.7 will need to upgrade their Python version or use an older `tbparse` version.
- breaking The behavior of the `event_types` parameter for `SummaryReader` was changed in v0.0.7. This might lead to unexpected filtering or empty results if you relied on the old behavior.
- breaking The `histogram` API was unified in v0.0.6. If you were using specific methods or parameters for histograms prior to this version, your code might break.
- gotcha While `tbparse` can parse many event types without `tensorflow` (especially after v0.0.9), full functionality for complex events like images, audio, or older tensor formats might still require `tensorflow` to be installed.
- breaking The parameters for `SummaryReader` were clarified and potentially changed in v0.0.3. This could affect code that directly instantiated `SummaryReader` with specific arguments in older versions.
Install
-
pip install tbparse
Imports
- SummaryReader
from tbparse import SummaryReader
Quickstart
import os
from tbparse import SummaryReader
# Create a dummy log directory for demonstration
log_dir = './logs/example_run'
if not os.path.exists(log_dir):
os.makedirs(log_dir)
# In a real scenario, TensorBoard logs would be generated here
# For this quickstart, we'll assume logs exist or will be generated later
# Example usage:
# Replace 'path/to/your/log_dir' with your actual TensorBoard log directory
try:
reader = SummaryReader(log_dir)
df = reader.scalars
print("Scalars DataFrame (first 5 rows):")
print(df.head())
if not df.empty:
# Access specific columns
print(f"\nAvailable tags: {df['tag'].unique()}")
except FileNotFoundError:
print(f"Warning: Log directory '{log_dir}' not found or empty. Please ensure TensorBoard logs are present.")
except Exception as e:
print(f"An error occurred: {e}")