Пример #1
0
 def as_default(self):
   """Enables summary writing within a `with` block."""
   if self._resource is None:
     yield self
   else:
     old = context.context().summary_writer_resource
     context.context().summary_writer_resource = self._resource
     yield self
     # Flushes the summary writer in eager mode or in graph functions, but not
     # in legacy graph mode (you're on your own there).
     with ops.device("cpu:0"):
       gen_summary_ops.flush_summary_writer(self._resource)
     context.context().summary_writer_resource = old
Пример #2
0
def flush(writer=None, name=None):
    """Forces summary writer to send any buffered data to storage.

  This operation blocks until that finishes.

  Args:
    writer: The `tf.summary.SummaryWriter` resource to flush.
      The thread default will be used if this parameter is None.
      Otherwise a `tf.no_op` is returned.
    name: A name for the operation (optional).

  Returns:
    The created `tf.Operation`.
  """
    if writer is None:
        writer = context.context().summary_writer
        if writer is None:
            return control_flow_ops.no_op()
    if isinstance(writer, ResourceSummaryWriter):
        resource = writer._resource  # pylint: disable=protected-access
    else:
        # Assume we were passed a raw resource tensor.
        resource = writer
    with ops.device("cpu:0"):
        return gen_summary_ops.flush_summary_writer(resource, name=name)
Пример #3
0
def flush(writer=None, name=None):
  """Forces summary writer to send any buffered data to storage.

  This operation blocks until that finishes.

  Args:
    writer: The `tf.summary.SummaryWriter` resource to flush.
      The thread default will be used if this parameter is None.
      Otherwise a `tf.no_op` is returned.
    name: A name for the operation (optional).

  Returns:
    The created `tf.Operation`.
  """
  if writer is None:
    writer = context.context().summary_writer
    if writer is None:
      return control_flow_ops.no_op()
  if isinstance(writer, ResourceSummaryWriter):
    resource = writer._resource  # pylint: disable=protected-access
  else:
    # Assume we were passed a raw resource tensor.
    resource = writer
  with ops.device("cpu:0"):
    return gen_summary_ops.flush_summary_writer(resource, name=name)
Пример #4
0
def flush(writer=None, name=None):
    """Forces summary writer to send any buffered data to storage.

  This operation blocks until that finishes.

  Args:
    writer: The @{tf.contrib.summary.SummaryWriter} resource to flush.
      The thread default will be used if this parameter is None.
      Otherwise a @{tf.no_op} is returned.
    name: A name for the operation (optional).

  Returns:
    The created @{tf.Operation}.
  """
    if writer is None:
        writer = context.context().summary_writer_resource
        if writer is None:
            return control_flow_ops.no_op()
    return gen_summary_ops.flush_summary_writer(writer, name=name)
Пример #5
0
def flush(writer=None, name=None):
  """Forces summary writer to send any buffered data to storage.

  This operation blocks until that finishes.

  Args:
    writer: The @{tf.contrib.summary.SummaryWriter} resource to flush.
      The thread default will be used if this parameter is None.
      Otherwise a @{tf.no_op} is returned.
    name: A name for the operation (optional).

  Returns:
    The created @{tf.Operation}.
  """
  if writer is None:
    writer = context.context().summary_writer_resource
    if writer is None:
      return control_flow_ops.no_op()
  return gen_summary_ops.flush_summary_writer(writer, name=name)
Пример #6
0
def flush(writer=None, name=None):
  """Forces summary writer to send any buffered data to storage.

  This operation blocks until that finishes.

  Args:
    writer: The `tf.summary.SummaryWriter` to flush. If None, the current
      default writer will be used instead; if there is no current writer, this
      returns `tf.no_op`.
    name: Ignored legacy argument for a name for the operation.

  Returns:
    The created `tf.Operation`.
  """
  if writer is None:
    writer = _summary_state.writer
    if writer is None:
      return control_flow_ops.no_op()
  if isinstance(writer, SummaryWriter):
    return writer.flush()
  else:
    # Legacy fallback in case we were passed a raw resource tensor.
    with ops.device("cpu:0"):
      return gen_summary_ops.flush_summary_writer(writer, name=name)
Пример #7
0
 def flush(self):
   """See `SummaryWriter.flush`."""
   with ops.device("cpu:0"):
     return gen_summary_ops.flush_summary_writer(self._resource)
Пример #8
0
 def flush(self):
   """See `SummaryWriter.flush`."""
   if context.executing_eagerly() and self._closed:
     return
   with ops.device("cpu:0"):
     return gen_summary_ops.flush_summary_writer(self._resource)