Defined in tensorflow/contrib/summary/summary.py
.
TensorFlow Summary API v2.
The operations in this package are safe to use with eager execution turned on or
off. It has a more flexible API that allows summaries to be written directly
from ops to places other than event log files, rather than propagating protos
from tf.summary.merge_all
to tf.summary.FileWriter
.
To use with eager execution enabled, write your code as follows:
global_step = tf.train.get_or_create_global_step()
summary_writer = tf.contrib.summary.create_file_writer(
train_dir, flush_millis=10000)
with summary_writer.as_default(), tf.contrib.summary.always_record_summaries():
# model code goes here
# and in it call
tf.contrib.summary.scalar("loss", my_loss)
# In this case every call to tf.contrib.summary.scalar will generate a record
# ...
To use it with graph execution, write your code as follows:
global_step = tf.train.get_or_create_global_step()
summary_writer = tf.contrib.summary.create_file_writer(
train_dir, flush_millis=10000)
with summary_writer.as_default(), tf.contrib.summary.always_record_summaries():
# model definition code goes here
# and in it call
tf.contrib.summary.scalar("loss", my_loss)
# In this case every call to tf.contrib.summary.scalar will generate an op,
# note the need to run tf.contrib.summary.all_summary_ops() to make sure these
# ops get executed.
# ...
train_op = ....
with tf.Session(...) as sess:
tf.global_variables_initializer().run()
tf.contrib.summary.initialize(graph=tf.get_default_graph())
# ...
while not_done_training:
sess.run([train_op, tf.contrib.summary.all_summary_ops()])
# ...
Classes
class SummaryWriter
: Encapsulates a stateful summary writer resource.
Functions
all_summary_ops(...)
: Graph-mode only. Returns all summary ops.
always_record_summaries(...)
: Sets the should_record_summaries Tensor to always true.
audio(...)
: Writes an audio summary if possible.
create_db_writer(...)
: Creates a summary database writer in the current context.
create_file_writer(...)
: Creates a summary file writer in the current context under the given name.
create_summary_file_writer(...)
: Please use tf.contrib.summary.create_file_writer
. (deprecated)
eval_dir(...)
: Construct a logdir for an eval summary writer.
flush(...)
: Forces summary writer to send any buffered data to storage.
generic(...)
: Writes a tensor summary if possible.
graph(...)
: Writes a TensorFlow graph to the summary interface.
histogram(...)
: Writes a histogram summary if possible.
image(...)
: Writes an image summary if possible.
import_event(...)
: Writes a tf.Event
binary proto.
initialize(...)
: Initializes summary writing for graph execution mode.
never_record_summaries(...)
: Sets the should_record_summaries Tensor to always false.
record_summaries_every_n_global_steps(...)
: Sets the should_record_summaries Tensor to true if global_step % n == 0.
scalar(...)
: Writes a scalar summary if possible.
should_record_summaries(...)
: Returns boolean Tensor which is true if summaries should be recorded.
summary_writer_initializer_op(...)
: Graph-mode only. Returns the list of ops to create all summary writers.