當前位置: 首頁>>代碼示例>>Python>>正文


Python gfile.IsDirectory方法代碼示例

本文整理匯總了Python中tensorflow.python.platform.gfile.IsDirectory方法的典型用法代碼示例。如果您正苦於以下問題:Python gfile.IsDirectory方法的具體用法?Python gfile.IsDirectory怎麽用?Python gfile.IsDirectory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow.python.platform.gfile的用法示例。


在下文中一共展示了gfile.IsDirectory方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from tensorflow.python.platform import gfile [as 別名]
# 或者: from tensorflow.python.platform.gfile import IsDirectory [as 別名]
def __init__(self, dump_root, partition_graphs=None, validate=True):
    """`DebugDumpDir` constructor.

    Args:
      dump_root: (`str`) path to the dump root directory.
      partition_graphs: A repeated field of GraphDefs representing the
          partition graphs executed by the TensorFlow runtime.
      validate: (`bool`) whether the dump files are to be validated against the
          partition graphs.

    Raises:
      IOError: If dump_root does not exist as a directory.
    """

    if not gfile.IsDirectory(dump_root):
      raise IOError("Dump root directory %s does not exist" % dump_root)

    self._core_metadata = None
    self._load_dumps(dump_root)
    self._create_tensor_watch_maps()
    self._load_partition_graphs(partition_graphs, validate)

    self._python_graph = None 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:25,代碼來源:debug_data.py

示例2: ListPlugins

# 需要導入模塊: from tensorflow.python.platform import gfile [as 別名]
# 或者: from tensorflow.python.platform.gfile import IsDirectory [as 別名]
def ListPlugins(logdir):
  """List all the plugins that have registered assets in logdir.

  If the plugins_dir does not exist, it returns an empty list. This maintains
  compatibility with old directories that have no plugins written.

  Args:
    logdir: A directory that was created by a TensorFlow events writer.

  Returns:
    a list of plugin names, as strings
  """
  plugins_dir = os.path.join(logdir, _PLUGINS_DIR)
  if not gfile.IsDirectory(plugins_dir):
    return []
  entries = gfile.ListDirectory(plugins_dir)
  return [x for x in entries if _IsDirectory(plugins_dir, x)] 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:19,代碼來源:plugin_asset_util.py

示例3: ListAssets

# 需要導入模塊: from tensorflow.python.platform import gfile [as 別名]
# 或者: from tensorflow.python.platform.gfile import IsDirectory [as 別名]
def ListAssets(logdir, plugin_name):
  """List all the assets that are available for given plugin in a logdir.

  Args:
    logdir: A directory that was created by a TensorFlow summary.FileWriter.
    plugin_name: A string name of a plugin to list assets for.

  Returns:
    A string list of available plugin assets. If the plugin subdirectory does
    not exist (either because the logdir doesn't exist, or because the plugin
    didn't register) an empty list is returned.
  """
  plugin_dir = PluginDirectory(logdir, plugin_name)
  if not gfile.IsDirectory(plugin_dir):
    return []
  entries = gfile.ListDirectory(plugin_dir)
  return [x for x in entries if not _IsDirectory(plugin_dir, x)] 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:19,代碼來源:plugin_asset_util.py

示例4: __init__

# 需要導入模塊: from tensorflow.python.platform import gfile [as 別名]
# 或者: from tensorflow.python.platform.gfile import IsDirectory [as 別名]
def __init__(self, dump_root, partition_graphs=None, validate=True):
    """`DebugDumpDir` constructor.

    Args:
      dump_root: (`str`) path to the dump root directory.
      partition_graphs: A repeated field of GraphDefs representing the
          partition graphs executed by the TensorFlow runtime.
      validate: (`bool`) whether the dump files are to be validated against the
          partition graphs.

    Raises:
      IOError: If dump_root does not exist as a directory.
    """

    if not gfile.IsDirectory(dump_root):
      raise IOError("Dump root directory %s does not exist" % dump_root)

    self._load_dumps(dump_root)
    self._create_tensor_watch_maps()
    self._load_partition_graphs(partition_graphs, validate)

    self._python_graph = None 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:24,代碼來源:debug_data.py

示例5: _get_checkpoint_filename

# 需要導入模塊: from tensorflow.python.platform import gfile [as 別名]
# 或者: from tensorflow.python.platform.gfile import IsDirectory [as 別名]
def _get_checkpoint_filename(ckpt_dir_or_file):
  """Returns checkpoint filename given directory or specific checkpoint file."""
  if gfile.IsDirectory(ckpt_dir_or_file):
    return saver.latest_checkpoint(ckpt_dir_or_file)
  return ckpt_dir_or_file 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:7,代碼來源:checkpoint_utils.py

示例6: __init__

# 需要導入模塊: from tensorflow.python.platform import gfile [as 別名]
# 或者: from tensorflow.python.platform.gfile import IsDirectory [as 別名]
def __init__(self, logdir, max_queue=10, flush_secs=120,
               filename_suffix=None):
    """Creates a `EventFileWriter` and an event file to write to.

    On construction the summary writer creates a new event file in `logdir`.
    This event file will contain `Event` protocol buffers, which are written to
    disk via the add_event method.

    The other arguments to the constructor control the asynchronous writes to
    the event file:

    *  `flush_secs`: How often, in seconds, to flush the added summaries
       and events to disk.
    *  `max_queue`: Maximum number of summaries or events pending to be
       written to disk before one of the 'add' calls block.

    Args:
      logdir: A string. Directory where event file will be written.
      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.
      filename_suffix: A string. Every event file's name is suffixed with
        `filename_suffix`.
    """
    self._logdir = logdir
    if not gfile.IsDirectory(self._logdir):
      gfile.MakeDirs(self._logdir)
    self._event_queue = six.moves.queue.Queue(max_queue)
    self._ev_writer = pywrap_tensorflow.EventsWriter(
        compat.as_bytes(os.path.join(self._logdir, "events")))
    self._flush_secs = flush_secs
    self._sentinel_event = self._get_sentinel_event()
    if filename_suffix:
      self._ev_writer.InitWithSuffix(compat.as_bytes(filename_suffix))
    self._closed = False
    self._worker = _EventLoggerThread(self._event_queue, self._ev_writer,
                                      self._flush_secs, self._sentinel_event)

    self._worker.start() 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:41,代碼來源:event_file_writer.py

示例7: _IsDirectory

# 需要導入模塊: from tensorflow.python.platform import gfile [as 別名]
# 或者: from tensorflow.python.platform.gfile import IsDirectory [as 別名]
def _IsDirectory(parent, item):
  """Helper that returns if parent/item is a directory."""
  return gfile.IsDirectory(os.path.join(parent, item)) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:5,代碼來源:plugin_asset_util.py

示例8: _get_checkpoint_filename

# 需要導入模塊: from tensorflow.python.platform import gfile [as 別名]
# 或者: from tensorflow.python.platform.gfile import IsDirectory [as 別名]
def _get_checkpoint_filename(filepattern):
  """Returns checkpoint filename given directory or specific filepattern."""
  if gfile.IsDirectory(filepattern):
    return saver.latest_checkpoint(filepattern)
  return filepattern 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:7,代碼來源:checkpoint_utils.py

示例9: testConstructWrapperWithExistingFileDumpRootRaisesException

# 需要導入模塊: from tensorflow.python.platform import gfile [as 別名]
# 或者: from tensorflow.python.platform.gfile import IsDirectory [as 別名]
def testConstructWrapperWithExistingFileDumpRootRaisesException(self):
    file_path = os.path.join(self.session_root, "foo")
    open(file_path, "a").close()  # Create the file
    self.assertTrue(gfile.Exists(file_path))
    self.assertFalse(gfile.IsDirectory(file_path))
    with self.assertRaisesRegexp(ValueError,
                                 "session_root path points to a file"):
      dumping_wrapper.DumpingDebugWrapperSession(
          session.Session(), session_root=file_path, log_usage=False) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:11,代碼來源:dumping_wrapper_test.py

示例10: __init__

# 需要導入模塊: from tensorflow.python.platform import gfile [as 別名]
# 或者: from tensorflow.python.platform.gfile import IsDirectory [as 別名]
def __init__(self, sess, session_root, watch_fn=None, log_usage=True):
    """Constructor of DumpingDebugWrapperSession.

    Args:
      sess: The TensorFlow `Session` object being wrapped.
      session_root: (`str`) Path to the session root directory. Must be a
        directory that does not exist or an empty directory. If the directory
        does not exist, it will be created by the debugger core during debug
        [`Session.run()`](../../../g3doc/api_docs/python/client.md#session.run)
        calls.
        As the `run()` calls occur, subdirectories will be added to
        `session_root`. The subdirectories' names has the following pattern:
          run_<epoch_time_stamp>_<uuid>
        E.g., run_1480734393835964_ad4c953a85444900ae79fc1b652fb324
      watch_fn: (`Callable`) A Callable that can be used to define per-run
        debug ops and watched tensors. See the doc of
        `NonInteractiveDebugWrapperSession.__init__()` for details.
      log_usage: (`bool`) whether the usage of this class is to be logged.

    Raises:
       ValueError: If `session_root` is an existing and non-empty directory or
       if `session_root` is a file.
    """

    if log_usage:
      pass  # No logging for open-source.

    framework.NonInteractiveDebugWrapperSession.__init__(
        self, sess, watch_fn=watch_fn)

    if gfile.Exists(session_root):
      if not gfile.IsDirectory(session_root):
        raise ValueError(
            "session_root path points to a file: %s" % session_root)
      elif gfile.ListDirectory(session_root):
        raise ValueError(
            "session_root path points to a non-empty directory: %s" %
            session_root)
    self._session_root = session_root 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:41,代碼來源:dumping_wrapper.py

示例11: __init__

# 需要導入模塊: from tensorflow.python.platform import gfile [as 別名]
# 或者: from tensorflow.python.platform.gfile import IsDirectory [as 別名]
def __init__(self, logdir, max_queue=10, flush_secs=120):
    """Creates a `EventFileWriter` and an event file to write to.

    On construction the summary writer creates a new event file in `logdir`.
    This event file will contain `Event` protocol buffers, which are written to
    disk via the add_event method.

    The other arguments to the constructor control the asynchronous writes to
    the event file:

    *  `flush_secs`: How often, in seconds, to flush the added summaries
       and events to disk.
    *  `max_queue`: Maximum number of summaries or events pending to be
       written to disk before one of the 'add' calls block.

    Args:
      logdir: A string. Directory where event file will be written.
      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.
    """
    self._logdir = logdir
    if not gfile.IsDirectory(self._logdir):
      gfile.MakeDirs(self._logdir)
    self._event_queue = six.moves.queue.Queue(max_queue)
    self._ev_writer = pywrap_tensorflow.EventsWriter(
        compat.as_bytes(os.path.join(self._logdir, "events")))
    self._closed = False
    self._worker = _EventLoggerThread(self._event_queue, self._ev_writer,
                                      flush_secs)

    self._worker.start() 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:34,代碼來源:event_file_writer.py

示例12: _get_checkpoint_filename

# 需要導入模塊: from tensorflow.python.platform import gfile [as 別名]
# 或者: from tensorflow.python.platform.gfile import IsDirectory [as 別名]
def _get_checkpoint_filename(ckpt_dir_or_file):
  """Returns checkpoint filename given directory or specific checkpoint file."""
  if gfile.IsDirectory(ckpt_dir_or_file):
    return checkpoint_management.latest_checkpoint(ckpt_dir_or_file)
  return ckpt_dir_or_file 
開發者ID:artyompal,項目名稱:tpu_models,代碼行數:7,代碼來源:checkpoint_utils.py

示例13: testGraphFromMetaGraphBecomesAvailable

# 需要導入模塊: from tensorflow.python.platform import gfile [as 別名]
# 或者: from tensorflow.python.platform.gfile import IsDirectory [as 別名]
def testGraphFromMetaGraphBecomesAvailable(self):
    """Test accumulator by writing values and then reading them."""

    directory = os.path.join(self.get_temp_dir(), 'metagraph_test_values_dir')
    if gfile.IsDirectory(directory):
      gfile.DeleteRecursively(directory)
    gfile.MkDir(directory)

    writer = tf.train.SummaryWriter(directory, max_queue=100)

    with tf.Graph().as_default() as graph:
      _ = tf.constant([2.0, 1.0])
    # Add a graph to the summary writer.
    meta_graph_def = saver.export_meta_graph(
        graph_def=graph.as_graph_def(add_shapes=True))
    writer.add_meta_graph(meta_graph_def)

    writer.flush()

    # Verify that we can load those events properly
    acc = ea.EventAccumulator(directory)
    acc.Reload()
    self.assertTagsEqual(
        acc.Tags(),
        {
            ea.IMAGES: [],
            ea.AUDIO: [],
            ea.SCALARS: [],
            ea.HISTOGRAMS: [],
            ea.COMPRESSED_HISTOGRAMS: [],
            ea.GRAPH: True,
            ea.META_GRAPH: True,
            ea.RUN_METADATA: []
        })
    self.assertProtoEquals(graph.as_graph_def(add_shapes=True), acc.Graph())
    self.assertProtoEquals(meta_graph_def, acc.MetaGraph()) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:38,代碼來源:event_accumulator_test.py

示例14: GetLogdirSubdirectories

# 需要導入模塊: from tensorflow.python.platform import gfile [as 別名]
# 或者: from tensorflow.python.platform.gfile import IsDirectory [as 別名]
def GetLogdirSubdirectories(path):
  """Returns subdirectories with event files on path."""
  if gfile.Exists(path) and not gfile.IsDirectory(path):
    raise ValueError('GetLogdirSubdirectories: path exists and is not a '
                     'directory, %s' % path)

  # ListRecursively just yields nothing if the path doesn't exist.
  return (
      subdir
      for (subdir, files) in io_wrapper.ListRecursively(path)
      if list(filter(event_accumulator.IsTensorFlowEventsFile, files))
  ) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:14,代碼來源:event_multiplexer.py

示例15: _AddEvents

# 需要導入模塊: from tensorflow.python.platform import gfile [as 別名]
# 或者: from tensorflow.python.platform.gfile import IsDirectory [as 別名]
def _AddEvents(path):
  if not gfile.IsDirectory(path):
    gfile.MakeDirs(path)
  fpath = os.path.join(path, 'hypothetical.tfevents.out')
  with gfile.GFile(fpath, 'w') as f:
    f.write('')
    return fpath 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:9,代碼來源:event_multiplexer_test.py


注:本文中的tensorflow.python.platform.gfile.IsDirectory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。