• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# ==============================================================================
15"""Reads Summaries from and writes Summaries to event files."""
16
17from __future__ import absolute_import
18from __future__ import division
19from __future__ import print_function
20
21# pylint: disable=unused-import
22from tensorflow.python.summary.summary_iterator import summary_iterator
23from tensorflow.python.summary.writer.writer import FileWriter as _FileWriter
24from tensorflow.python.summary.writer.writer_cache import FileWriterCache as SummaryWriterCache
25# pylint: enable=unused-import
26from tensorflow.python.util.deprecation import deprecated
27
28
29class SummaryWriter(_FileWriter):
30
31  @deprecated("2016-11-30",
32              "Please switch to tf.summary.FileWriter. The interface and "
33              "behavior is the same; this is just a rename.")
34  def __init__(self,
35               logdir,
36               graph=None,
37               max_queue=10,
38               flush_secs=120,
39               graph_def=None):
40    """Creates a `SummaryWriter` and an event file.
41
42    This class is deprecated, and should be replaced with tf.summary.FileWriter.
43
44    On construction the summary writer creates a new event file in `logdir`.
45    This event file will contain `Event` protocol buffers constructed when you
46    call one of the following functions: `add_summary()`, `add_session_log()`,
47    `add_event()`, or `add_graph()`.
48
49    If you pass a `Graph` to the constructor it is added to
50    the event file. (This is equivalent to calling `add_graph()` later).
51
52    TensorBoard will pick the graph from the file and display it graphically so
53    you can interactively explore the graph you built. You will usually pass
54    the graph from the session in which you launched it:
55
56    ```python
57    ...create a graph...
58    # Launch the graph in a session.
59    sess = tf.compat.v1.Session()
60    # Create a summary writer, add the 'graph' to the event file.
61    writer = tf.compat.v1.summary.FileWriter(<some-directory>, sess.graph)
62    ```
63
64    The other arguments to the constructor control the asynchronous writes to
65    the event file:
66
67    *  `flush_secs`: How often, in seconds, to flush the added summaries
68       and events to disk.
69    *  `max_queue`: Maximum number of summaries or events pending to be
70       written to disk before one of the 'add' calls block.
71
72    Args:
73      logdir: A string. Directory where event file will be written.
74      graph: A `Graph` object, such as `sess.graph`.
75      max_queue: Integer. Size of the queue for pending events and summaries.
76      flush_secs: Number. How often, in seconds, to flush the
77        pending events and summaries to disk.
78      graph_def: DEPRECATED: Use the `graph` argument instead.
79    """
80    super(SummaryWriter, self).__init__(logdir, graph, max_queue, flush_secs,
81                                        graph_def)
82