trieste.logging#

This module contains logging utilities.

Module Contents#

default_summary_filter(name: str) bool[source]#

Default summary filter: omits any names that start with _.

set_tensorboard_writer(summary_writer: tensorflow.summary.SummaryWriter | None) None[source]#

Set a SummaryWriter instance to use for logging to TensorBoard, or None to disable.

Parameters:

summary_writer – optional summary writer instance.

get_tensorboard_writer() tensorflow.summary.SummaryWriter | None[source]#

Returns a SummaryWriter instance to use for logging to TensorBoard, or None.

Returns:

optional summary writer instance.

tensorboard_writer(summary_writer: tensorflow.summary.SummaryWriter | None) Iterator[None][source]#

A context manager for setting or overriding a TensorBoard summary writer inside a code block.

Parameters:

summary_writer – optional summary writer instance.

set_step_number(new_step_number: int) None[source]#

Set an optimization step number to use for logging purposes.

Parameters:

new_step_number – new current step number

Raises:

ValueError – if step_number < 0

get_step_number() int[source]#

Get the optimization step number used for logging purposes.

Returns:

current step number.

step_number(new_step_number: int) Iterator[None][source]#

A context manager for setting or overriding the optimization step number inside a code block.

Parameters:

new_step_number – new current step number

set_summary_filter(summary_filter: SummaryFilter) None[source]#

Set a filter on summary names. The default is to only omit names that start with _.

Parameters:

summary_filter – new summary filter

get_summary_filter() SummaryFilter[source]#

Get the current filter on summary names. The default is to only omit names that start with _.

Returns:

current summary filter.

get_current_name_scope() str[source]#

Returns the full name scope. Copied from TF 2.5.

include_summary(name: str) bool[source]#

Whether a summary name should be included.

Param:

full summary name (including name spaces)

Returns:

whether the summary should be included.

evaluate_data(data: T | Callable[[], T]) T[source]#

Return the passed in data, evaluating it if it’s inside a closure.

histogram(name: str, data: trieste.types.TensorType | Callable[[], trieste.types.TensorType], **kwargs: Any) bool[source]#

Wrapper for tf.summary.histogram that first filters out unwanted summaries by name. Accepts either data or closures that only get evaluated when logged.

scalar(name: str, data: float | Callable[[], float], **kwargs: Any) bool[source]#

Wrapper for tf.summary.scalar that first filters out unwanted summaries by name. Accepts either data or closures that only get evaluated when logged.

text(name: str, data: str | Callable[[], str], **kwargs: Any) bool[source]#

Wrapper for tf.summary.text that first filters out unwanted summaries by name. Accepts either data or closures that only get evaluated when logged.

pyplot(name: str, figure: matplotlib.figure.Figure | Callable[[], matplotlib.figure.Figure]) bool[source]#

Utility function for passing a matplotlib figure to tf.summary.image. Accepts either data or closures that only get evaluated when logged.