View source on GitHub

A stateful resource that aggregates statistics from one or more iterators.

To record statistics, use one of the custom transformation functions defined in this module when defining your All statistics will be aggregated by the StatsAggregator that is associated with a particular iterator (see below). For example, to record the latency of producing each element by iterating over a dataset:

dataset = ...
dataset = dataset.apply("total_bytes"))

To associate a StatsAggregator with a object, use the following pattern:

aggregator =
dataset = ...

# Apply `StatsOptions` to associate `dataset` with `aggregator`.
options =
options.experimental_stats.aggregator = aggregator
dataset = dataset.with_options(options)

To get a protocol buffer summary of the currently aggregated statistics, use the StatsAggregator.get_summary() tensor. The easiest way to do this is to add the returned tensor to the tf.GraphKeys.SUMMARIES collection, so that the summaries will be included with any existing summaries.

aggregator =
# ...
stats_summary = aggregator.get_summary()
tf.compat.v1.add_to_collection(tf.GraphKeys.SUMMARIES, stats_summary)



View source

Returns a string tf.Tensor that summarizes the aggregated statistics.

The returned tensor will contain a serialized tf.compat.v1.summary.Summary protocol buffer, which can be used with the standard TensorBoard logging facilities.

A scalar string tf.Tensor that summarizes the aggregated statistics.