SummaryCollector

class tfsnippet.utils.SummaryCollector(collections=None, no_add_to_collections=False)

Bases: object

Collecting summaries and histograms added by tfsnippet.add_summary() and tfsnippet.add_histogram(). For example:

collector = SummaryCollector()
with collector.as_default():
    spt.add_summary(...)
summary_op = collector.merge_summary()

You may also use this collector to capture the auto histogram generated by layers from tfsnippet.layers, for example:

collector = SummaryCollector()
with collector.as_default(auto_histogram=True):
    y = spt.layers.dense(x, ...)
summary_op = collector.merge_summary()

Attributes Summary

collections Get the summary collections.
summary_list Get the list of captured summaries.

Methods Summary

add_histogram(tensor[, summary_name, …]) Add the histogram of tensor to this collector and to collections.
add_summary(summary[, collections]) Add the summary to this collector and to collections.
as_default(**kwds) Push this SummaryCollector to the top of context stack, and enter a scoped context.
merge_summary() Merge all the captured summaries into one operation.

Attributes Documentation

collections

Get the summary collections.

summary_list

Get the list of captured summaries.

Methods Documentation

add_histogram(tensor, summary_name=None, strip_scope=False, collections=None, name=None)

Add the histogram of tensor to this collector and to collections.

Parameters:
  • tensor – Take histogram of this tensor.
  • summary_name – Specify the summary name for tensor.
  • strip_scope – If True, strip the name scope from tensor.name when adding the histogram.
  • collections – Also add the histogram to these collections. Defaults to self.collections.
  • name (str) – Default name of the name scope. If not specified, generate one according to the method name.
Returns:

The serialized histogram tensor of tensor.

add_summary(summary, collections=None)

Add the summary to this collector and to collections.

Parameters:
  • summary – TensorFlow summary tensor.
  • collections – Also add the summary to these collections. Defaults to self.collections.
Returns:

The summary tensor.

as_default(**kwds)

Push this SummaryCollector to the top of context stack, and enter a scoped context.

Parameters:auto_histogram (bool) – If specified, set the config value of tfsnippet.settings.auto_histogram within the context.
Yields:This summary collector object.
merge_summary()

Merge all the captured summaries into one operation.

Returns:
The merged operation, or None if no
summary has been captured.
Return type:tf.Operation or None