ML Community Day is November 9! Join us for updates from TensorFlow, JAX, and more Learn more


Writes Summary protocol buffers to event files.

The FileWriter class provides a mechanism to create an event file in a given directory and add summaries and events to it. The class updates the file contents asynchronously. This allows a training program to call methods to add data to the file directly from the training loop, without slowing down training.

When constructed with a tf.compat.v1.Session parameter, a FileWriter instead forms a compatibility layer over new graph-based summaries to facilitate the use of new summary writing with pre-existing code that expects a FileWriter instance.

This class is not thread-safe.

logdir A string. Directory where event file will be written.
graph A Graph object, such as sess.graph.
max_queue Integer. Size of the queue for pending events and summaries.
flush_secs Number. How often, in seconds, to flush the pending events and summaries to disk.
graph_def DEPRECATED: Use the graph argument instead.
filename_suffix A string. Every event file's name is suffixed with suffix.
session A tf.compat.v1.Session object. See details above.

RuntimeError If called with eager execution enabled.



View source

Adds an event to the event file.

event An Event protocol buffer.


View source

Adds a Graph to the event file.

The graph described by the protocol buffer will be displayed by TensorBoard. Most users pass a graph in the constructor instead.

graph A Graph object, such as sess.graph.
global_step Number. Optional global step counter to record with the graph.
graph_def DEPRECATED. Use the graph parameter instead.

ValueError If both graph and graph_def are passed to the method.


View source

Adds a MetaGraphDef to the event file.

The MetaGraphDef allows running the given graph via saver.import_meta_graph().

meta_graph_def A MetaGraphDef object, o