MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / initialize

Function initialize

tensorflow/python/ops/summary_ops_v2.py:292–330  ·  view source on GitHub ↗

Initializes summary writing for graph execution mode. This operation is a no-op when executing eagerly. This helper method provides a higher-level alternative to using `tf.contrib.summary.summary_writer_initializer_op` and `tf.contrib.summary.graph`. Most users will also want to call `t

(
    graph=None,  # pylint: disable=redefined-outer-name
    session=None)

Source from the content-addressed store, hash-verified

290
291@tf_export(v1=["summary.initialize"])
292def initialize(
293 graph=None, # pylint: disable=redefined-outer-name
294 session=None):
295 """Initializes summary writing for graph execution mode.
296
297 This operation is a no-op when executing eagerly.
298
299 This helper method provides a higher-level alternative to using
300 `tf.contrib.summary.summary_writer_initializer_op` and
301 `tf.contrib.summary.graph`.
302
303 Most users will also want to call `tf.compat.v1.train.create_global_step`
304 which can happen before or after this function is called.
305
306 Args:
307 graph: A `tf.Graph` or `tf.compat.v1.GraphDef` to output to the writer.
308 This function will not write the default graph by default. When
309 writing to an event log file, the associated step will be zero.
310 session: So this method can call `tf.Session.run`. This defaults
311 to `tf.compat.v1.get_default_session`.
312
313 Raises:
314 RuntimeError: If the current thread has no default
315 `tf.contrib.summary.SummaryWriter`.
316 ValueError: If session wasn't passed and no default session.
317 """
318 if context.executing_eagerly():
319 return
320 if context.context().summary_writer is None:
321 raise RuntimeError("No default tf.contrib.summary.SummaryWriter found")
322 if session is None:
323 session = ops.get_default_session()
324 if session is None:
325 raise ValueError("session must be passed if no default session exists")
326 session.run(summary_writer_initializer_op())
327 if graph is not None:
328 data = _serialize_graph(graph)
329 x = array_ops.placeholder(dtypes.string)
330 session.run(_graph(x, 0), feed_dict={x: data})
331
332
333@tf_export("summary.create_file_writer", v1=[])

Callers 1

ConstantFoldFallbackHookFunction · 0.50

Calls 6

_serialize_graphFunction · 0.85
executing_eagerlyMethod · 0.80
contextMethod · 0.45
runMethod · 0.45
placeholderMethod · 0.45

Tested by

no test coverage detected