Type FileWriter
Namespace tensorflow.summary
Parent SummaryToEventTransformer
Interfaces IFileWriter, IContextManager<T>
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
(
tf.contrib.summary
) to facilitate the use of new summary writing with
pre-existing code that expects a `FileWriter` instance.
Methods
Properties
Public instance methods
object add_event_dyn(object event)
Adds an event to the event file.
Parameters
-
object
event - An `Event` protocol buffer.
void add_graph(object graph, Nullable<int> global_step, Graph graph_def)
object get_logdir_dyn()
Returns the directory where event file will be written.
Public static methods
FileWriter NewDyn(object logdir, object graph, ImplicitContainer<T> max_queue, ImplicitContainer<T> flush_secs, object graph_def, object filename_suffix, object session)
Creates a `FileWriter`, optionally shared within the given session. Typically, constructing a file writer creates a new event file in `logdir`.
This event file will contain `Event` protocol buffers constructed when you
call one of the following functions: `add_summary()`, `add_session_log()`,
`add_event()`, or `add_graph()`. If you pass a `Graph` to the constructor it is added to
the event file. (This is equivalent to calling `add_graph()` later). TensorBoard will pick the graph from the file and display it graphically so
you can interactively explore the graph you built. You will usually pass
the graph from the session in which you launched it:
The `session` argument to the constructor makes the returned `FileWriter` a
compatibility layer over new graph-based summaries (
tf.contrib.summary
).
Crucially, this means the underlying writer resource and events file will
be shared with any other `FileWriter` using the same `session` and `logdir`,
and with any tf.contrib.summary.SummaryWriter
in this session using the
the same shared resource name (which by default scoped to the logdir). If
no such resource exists, one will be created using the remaining arguments
to this constructor, but if one already exists those arguments are ignored.
In either case, ops will be added to `session.graph` to control the
underlying file writer resource. See tf.contrib.summary
for more details.
Parameters
-
object
logdir - A string. Directory where event file will be written.
-
object
graph - A `Graph` object, such as `sess.graph`.
-
ImplicitContainer<T>
max_queue - Integer. Size of the queue for pending events and summaries.
-
ImplicitContainer<T>
flush_secs - Number. How often, in seconds, to flush the pending events and summaries to disk.
-
object
graph_def - DEPRECATED: Use the `graph` argument instead.
-
object
filename_suffix - A string. Every event file's name is suffixed with `suffix`.
-
object
session - A `tf.compat.v1.Session` object. See details above.
Show Example
...create a graph... # Launch the graph in a session. sess = tf.compat.v1.Session() # Create a summary writer, add the 'graph' to the event file. writer = tf.compat.v1.summary.FileWriter(, sess.graph)