API Reference
Provides a SummaryReader class that will read all tensorboard events and summaries in a directory contains multiple event files, or a single event file.
- class tbparse.SummaryReader(log_path: str, *, pivot=False, extra_columns=None, event_types=None)[source]
Creates a SummaryReader that reads all tensorboard events and summaries stored in a event file or a directory containing multiple event files.
The constructor of SummaryReader. Columns contains step, tag, and value by default.
- Parameters:
log_path (str) – Load directory location, or load file location.
pivot (bool) – Returns long format DataFrame by default, returns wide format DataFrame if set to True. If there are multiple values per step with the same tag, the values are merged into a list.
extra_columns (Set[{'dir_name', 'file_name', 'wall_time', 'min', 'max', 'num', 'sum', 'sum_squares', 'width', 'height', 'content_type', 'length_frames', 'sample_rate'}]) –
Specifies extra columns, defaults to None.
dir_name: add a column that contains the relative directory path.
file_name: add a column that contains the relative event file path.
wall_time: add a column that stores the event timestamp.
min (histogram): the min value in the histogram.
max (histogram): the max value in the histogram.
num (histogram): the number of values in the histogram.
sum (histogram): the sum of all values in the histogram.
sum_squares (histogram): the sum of squares for all values in the histogram.
width (image): the width of the image.
height (image): the height of the image.
content_type (audio): the content type of the audio.
length_frames (audio): the length of the audio.
sample_rate (audio): the sampling rate of the audio.
event_types (Set[{'scalars', 'tensors', 'histograms', 'images', 'audio', 'hparams', 'text'}]) – Specifies the event types to parse, defaults to all event types.
- property audio: DataFrame
Construct a pandas.DataFrame that stores all audio events under log_path. Some processing is performed when evaluating this property. Therefore you may want to store the results and reuse it for better performance.
- Returns:
A DataFrame storing all audio events.
- Return type:
- static buckets_to_histogram_dict(lst: ndarray) Dict[str, Any] [source]
Convert a list of buckets to histogram dictionary. (deprecated, use tensor_to_histogram instead)
- Parameters:
lst (np.ndarray) – A [[‘bucket lower’, ‘bucket upper’, ‘bucket count’]] list. The range of the bucket is [lower, upper)
- Returns:
A {hist_data_name: hist_data} dictionary.
- Return type:
Dict[str, Any]
- property children: Dict[str, SummaryReader]
Returns a list of references to the children SummaryReader s. Since each child may have their own children, the underlying data structure is actually a tree that mirrors the directories and files in the file system.
- Returns:
A {childName: SummaryReader} dictionary.
- Return type:
Dict[str, ‘SummaryReader’]
- get_events(event_type: str) DataFrame [source]
Construct a pandas.DataFrame that stores all event_type events under log_path. Some processing is performed when evaluating this property. Therefore you may want to store the results and reuse it for better performance.
- Raises:
ValueError – if event_type is unknown.
- Returns:
A DataFrame storing all event_type events.
- Return type:
- get_raw_events(event_type: str | None = None, tag: str | None = None, event_acc: EventAccumulator | None = None) List[Any] | Dict[str, List[Any]] | Dict[str, Dict[str, List[Any]]] [source]
Returns a list of raw events for the specified raw event type. If tag is None, return a dictionary containing a list of raw events for each raw event type. If event_type is None, return a dictionary of dictionary containing a list of raw events for each raw event type. This function is only supported when log_path is a event file.
- Raises:
ValueError – if log_path is a directory.
KeyError – if event_type is unknown.
KeyError – If the tag is not found.
- Returns:
A [‘list’, ‘of’, ‘events’] list, or a {tag: [‘list’, ‘of’, ‘events’]} dictionary, or a {eventType: {tag: [‘list’, ‘of’, ‘events’]}} dictionary.
- Return type:
List[Any] | Dict[str, List[Any]] | Dict[str, Dict[str, List[Any]]]
- get_raw_tags(event_type: str | None = None, event_acc: EventAccumulator | None = None) List[str] | Dict[str, List[str]] [source]
Returns a list of raw tags for the specified raw event type. If event_type is None, return a dictionary containing a list of raw tags for each raw event type. This function is only supported when log_path is a event file.
- Parameters:
event_type ({None, 'images', 'audio', 'histograms', 'scalars', 'tensors', 'graph', 'meta_graph', 'run_metadata', 'hparams', 'text'}, optional) – the event type to retrieve, None means return all, defaults to None.
- Raises:
ValueError – if log_path is a directory.
ValueError – if event_type is unknown.
- Returns:
A [‘list’, ‘of’, ‘tags’] list, or a {eventType: [‘list’, ‘of’, ‘tags’]} dictionary.
- Return type:
- get_tags(event_type: str | None = None) List[str] | Dict[str, List[str]] [source]
Returns a list of tag names for the specified event type. If event_type is None, return a dictionary containing a list of tag names for each event type.
- Parameters:
event_type ({None, 'scalars', 'tensors', 'histograms', 'images', 'audio', 'hparams', 'text'}, optional) – the event type to retrieve, None means return all, defaults to None.
- Raises:
ValueError – if event_type is unknown.
- Returns:
A [‘list’, ‘of’, ‘tags’] list, or a {eventType: [‘list’, ‘of’, ‘tags’]} dictionary.
- Return type:
- static histogram_to_bins(counts: ndarray, limits: ndarray, lower_bound: float | None = None, upper_bound: float | None = None, n_bins: int = 30)[source]
Returns the pair (c, y), which are the corresponding c (bin center) and y (counts in bucket), given the bucket counts and limits.
- Parameters:
counts (np.ndarray) – The number of values inside the buckets. The first value must be zero.
limits (np.ndarray) – The (right) edges of the buckets. The first value is the left edge of the first bucket.
lower_bound (float) – The left edge of the first bin.
upper_bound (float) – The right edge of the last bin.
n_bins (int) – The number of output bins.
- Returns:
The tuple containing the bin center and the counts in each bucket.
- Return type:
Tuple[np.ndarray, np.ndarray]
- static histogram_to_cdf(counts: ndarray, limits: ndarray, x: ndarray) ndarray [source]
Given an array of x (values), returns the linear interpolation of its corresponding y (cumulative probability), given the bucket counts and limits.
- Parameters:
counts (np.ndarray) – The number of values inside the buckets. The first value must be zero.
limits (np.ndarray) – The (right) edges of the buckets. The first value is the left edge of the first bucket.
x (np.ndarray) – The input values of x coordinates.
- Returns:
y, the cumulative probability at values x.
- Return type:
np.ndarray
- static histogram_to_pdf(counts: ndarray, limits: ndarray, x: ndarray) Tuple[ndarray, ndarray] [source]
Given an array of x (values), returns the pair (c, y), which are the corresponding c (bucket center) and the linear interpolation of its y (probability density in bucket), given the bucket counts and limits.
- Parameters:
counts (np.ndarray) – The number of values inside the buckets. The first value must be zero.
limits (np.ndarray) – The (right) edges of the buckets. The first value is the left edge of the first bucket.
x (np.ndarray) – The input values of x.
- Returns:
The tuple containing the bucket center and the probability density of the bucket.
- Return type:
Tuple[np.ndarray, np.ndarray]
- property histograms: DataFrame
Construct a pandas.DataFrame that stores all histograms events under log_path. Some processing is performed when evaluating this property. Therefore you may want to store the results and reuse it for better performance.
- Returns:
A DataFrame storing all histograms events.
- Return type:
- property hparams: DataFrame
Construct a pandas.DataFrame that stores all hparams events under log_path. Some processing is performed when evaluating this property. Therefore you may want to store the results and reuse it for better performance.
- Returns:
A DataFrame storing all hparams events.
- Return type:
- property images: DataFrame
Construct a pandas.DataFrame that stores all images events under log_path`. Some processing is performed when evaluating this property. Therefore you may want to store the results and reuse it for better performance.
- Returns:
A DataFrame storing all images events.
- Return type:
- property log_path: str
Load directory location, or load file location.
- Returns:
A directory path or file path.
- Return type:
- property raw_events: Dict[str, Dict[str, List[Any]]]
Returns a dictionary of dictionary containing a list of raw events for each raw event type. This property is only supported when log_path is a event file.
- property raw_tags: Dict[str, List[str]]
Returns a dictionary containing a list of raw tags for each raw event type. This property is only supported when log_path is a event file.
- property scalars: DataFrame
Construct a pandas.DataFrame that stores all scalar events under log_path. Some processing is performed when evaluating this property. Therefore you may want to store the results and reuse it for better performance.
- Returns:
A DataFrame storing all scalar events.
- Return type:
- property tags: Dict[str, List[str]]
Returns a dictionary contatining a list of parsed tag names for each event type.
- static tensor_to_audio(tensor: ndarray) Dict[str, Any] [source]
Convert a audio to audio dictionary.
- Parameters:
tensor (np.ndarray) – A [[‘encoded audio’, b’’], …] list.
- Returns:
A {audio_data_name: audio_data} dictionary.
- Return type:
Dict[str, Any]
- static tensor_to_histogram(tensor: ndarray) Dict[str, Any] [source]
Convert a tensor to histogram dictionary.
- Parameters:
tensor (np.ndarray) – A [[‘left edge’, ‘right edge’, ‘count’]] list. The range of the bucket is [lower, upper)
- Returns:
A {hist_data_name: hist_data} dictionary.
- Return type:
Dict[str, Any]
- static tensor_to_image(tensor: ndarray) Dict[str, Any] [source]
Convert a tensor to image dictionary.
- Parameters:
tensor (np.ndarray) – A [‘width’, ‘height’, ‘encoded image’, …] list.
- Returns:
A {image_data_name: image_data} dictionary.
- Return type:
Dict[str, Any]
- property tensors: DataFrame
Construct a pandas.DataFrame that stores all tensor events under log_path. Some processing is performed when evaluating this property. Therefore you may want to store the results and reuse it for better performance.
- Returns:
A DataFrame storing all tensor events.
- Return type:
- property text: DataFrame
Construct a pandas.DataFrame that stores all text events under log_path. Some processing is performed when evaluating this property. Therefore you may want to store the results and reuse it for better performance.
- Returns:
A DataFrame storing all hparams events.
- Return type: