当前位置: 首页>>代码示例>>Python>>正文


Python gfile.Exists方法代码示例

本文整理汇总了Python中tensorflow.gfile.Exists方法的典型用法代码示例。如果您正苦于以下问题:Python gfile.Exists方法的具体用法?Python gfile.Exists怎么用?Python gfile.Exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tensorflow.gfile的用法示例。


在下文中一共展示了gfile.Exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from tensorflow import gfile [as 别名]
# 或者: from tensorflow.gfile import Exists [as 别名]
def main(unused_argv):
  request = inference_flags.request_from_flags()

  if not gfile.Exists(request.segmentation_output_dir):
    gfile.MakeDirs(request.segmentation_output_dir)

  bbox = bounding_box_pb2.BoundingBox()
  text_format.Parse(FLAGS.bounding_box, bbox)

  runner = inference.Runner()
  runner.start(request)
  runner.run((bbox.start.z, bbox.start.y, bbox.start.x),
             (bbox.size.z, bbox.size.y, bbox.size.x))

  counter_path = os.path.join(request.segmentation_output_dir, 'counters.txt')
  if not gfile.Exists(counter_path):
    runner.counters.dump(counter_path) 
开发者ID:google,项目名称:ffn,代码行数:19,代码来源:run_inference.py

示例2: get_meta_filename

# 需要导入模块: from tensorflow import gfile [as 别名]
# 或者: from tensorflow.gfile import Exists [as 别名]
def get_meta_filename(self, start_new_model, train_dir):
    if start_new_model:
      logging.info("%s: Flag 'start_new_model' is set. Building a new model.",
                   task_as_string(self.task))
      return None
    
    latest_checkpoint = tf.train.latest_checkpoint(train_dir)
    if not latest_checkpoint: 
      logging.info("%s: No checkpoint file found. Building a new model.",
                   task_as_string(self.task))
      return None
    
    meta_filename = latest_checkpoint + ".meta"
    if not gfile.Exists(meta_filename):
      logging.info("%s: No meta graph file found. Building a new model.",
                     task_as_string(self.task))
      return None
    else:
      return meta_filename 
开发者ID:antoine77340,项目名称:Youtube-8M-WILLOW,代码行数:21,代码来源:train.py

示例3: get_meta_filename

# 需要导入模块: from tensorflow import gfile [as 别名]
# 或者: from tensorflow.gfile import Exists [as 别名]
def get_meta_filename(self, start_new_model, train_dir):
        if start_new_model:
            logging.info("%s: Flag 'start_new_model' is set. Building a new model.",
                         task_as_string(self.task))
            return None

        latest_checkpoint = tf.train.latest_checkpoint(train_dir)
        if not latest_checkpoint:
            logging.info("%s: No checkpoint file found. Building a new model.",
                         task_as_string(self.task))
            return None

        meta_filename = latest_checkpoint + ".meta"
        if not gfile.Exists(meta_filename):
            logging.info("%s: No meta graph file found. Building a new model.",
                         task_as_string(self.task))
            return None
        else:
            return meta_filename 
开发者ID:wangheda,项目名称:youtube-8m,代码行数:21,代码来源:train-with-rebuild.py

示例4: get_meta_filename

# 需要导入模块: from tensorflow import gfile [as 别名]
# 或者: from tensorflow.gfile import Exists [as 别名]
def get_meta_filename(self, start_new_model, train_dir):
    if start_new_model:
      logging.info("%s: Flag 'start_new_model' is set. Building a new model.",
                   task_as_string(self.task))
      return None

    latest_checkpoint = tf.train.latest_checkpoint(train_dir)
    if not latest_checkpoint:
      logging.info("%s: No checkpoint file found. Building a new model.",
                   task_as_string(self.task))
      return None

    meta_filename = latest_checkpoint + ".meta"
    if not gfile.Exists(meta_filename):
      logging.info("%s: No meta graph file found. Building a new model.",
                     task_as_string(self.task))
      return None
    else:
      return meta_filename 
开发者ID:wangheda,项目名称:youtube-8m,代码行数:21,代码来源:train_embedding.py

示例5: get_meta_filename

# 需要导入模块: from tensorflow import gfile [as 别名]
# 或者: from tensorflow.gfile import Exists [as 别名]
def get_meta_filename(self, start_new_model, train_dir):
    if start_new_model:
      logging.info("%s: Flag 'start_new_model' is set. Building a new model.",
                   task_as_string(self.task))
      return None

    latest_checkpoint = tf.train.latest_checkpoint(train_dir)
    if not latest_checkpoint:
      logging.info("%s: No checkpoint file found. Building a new model.",
                   task_as_string(self.task))
      return None

    meta_filename = latest_checkpoint + ".meta"
    if not gfile.Exists(meta_filename):
      logging.info("%s: No meta graph file found. Building a new model.",
                   task_as_string(self.task))
      return None
    else:
      return meta_filename 
开发者ID:google,项目名称:youtube-8m,代码行数:21,代码来源:train.py

示例6: count_file

# 需要导入模块: from tensorflow import gfile [as 别名]
# 或者: from tensorflow.gfile import Exists [as 别名]
def count_file(self, path, verbose=False, add_eos=False):
        if verbose: print('counting file {} ...'.format(path))
        assert exists(path)

        sents = []
        with open(path, 'r') as f:
            for idx, line in enumerate(f):
                if verbose and idx > 0 and idx % 500000 == 0:
                    print('  line {}'.format(idx))
                symbols = self.tokenize(line, add_eos=True)
                self.counter.update(symbols)
                sents.append(symbols)

        return sents

    # 更新counter 中的token 
开发者ID:GaoPeng97,项目名称:transformer-xl-chinese,代码行数:18,代码来源:vocabulary.py

示例7: encode_file

# 需要导入模块: from tensorflow import gfile [as 别名]
# 或者: from tensorflow.gfile import Exists [as 别名]
def encode_file(self, path, ordered=False, verbose=False,
                    add_double_eos=False):
        if verbose: print('encoding file {} ...'.format(path))
        assert exists(path)
        encoded = []
        with open(path, 'r') as f:
            for idx, line in enumerate(f):
                if verbose and idx > 0 and idx % 500000 == 0:
                    print('  line {}'.format(idx))
                symbols = self.tokenize(line, add_eos=True, add_double_eos=add_double_eos)

                encoded.append(self.convert_to_nparray(symbols))

        if ordered:
            encoded = np.concatenate(encoded)

        return encoded

    # 
开发者ID:GaoPeng97,项目名称:transformer-xl-chinese,代码行数:21,代码来源:vocabulary.py

示例8: main

# 需要导入模块: from tensorflow import gfile [as 别名]
# 或者: from tensorflow.gfile import Exists [as 别名]
def main(unused_argv):
    del unused_argv  # Unused

    corpus = get_lm_corpus(FLAGS.data_dir, FLAGS.dataset)  #

    save_dir = os.path.join(FLAGS.data_dir, "tfrecords")
    if not exists(save_dir):
        makedirs(save_dir)

    # test mode
    if FLAGS.per_host_test_bsz > 0:
        corpus.convert_to_tfrecords("test", save_dir, FLAGS.per_host_test_bsz,
                                    FLAGS.tgt_len, FLAGS.num_core_per_host,
                                    FLAGS=FLAGS)
        return

    for split, batch_size in zip(
            ["train", "valid"],
            [FLAGS.per_host_train_bsz, FLAGS.per_host_valid_bsz]):

        if batch_size <= 0: continue
        print("Converting {} set...".format(split))
        corpus.convert_to_tfrecords(split, save_dir, batch_size, FLAGS.tgt_len,
                                    FLAGS.num_core_per_host, FLAGS=FLAGS) 
开发者ID:GaoPeng97,项目名称:transformer-xl-chinese,代码行数:26,代码来源:data_utils.py

示例9: count_file

# 需要导入模块: from tensorflow import gfile [as 别名]
# 或者: from tensorflow.gfile import Exists [as 别名]
def count_file(self, path, verbose=False, add_eos=False):
        if verbose: print('counting file {} ...'.format(path))
        assert exists(path)

        sents = []
        with open(path, 'r') as f:
            for idx, line in enumerate(f):
                if verbose and idx > 0 and idx % 500000 == 0:
                    print('  line {}'.format(idx))
                symbols = self.tokenize(line, add_eos=add_eos)
                self.counter.update(symbols)
                sents.append(symbols)

        return sents

    # 更新counter 中的token 
开发者ID:GaoPeng97,项目名称:transformer-xl-chinese,代码行数:18,代码来源:old_vocabulary.py

示例10: encode_file

# 需要导入模块: from tensorflow import gfile [as 别名]
# 或者: from tensorflow.gfile import Exists [as 别名]
def encode_file(self, path, ordered=False, verbose=False, add_eos=True,
          add_double_eos=False):
    if verbose: print('encoding file {} ...'.format(path))
    assert exists(path)
    encoded = []
    with open(path, 'r') as f:
      for idx, line in enumerate(f):
        if verbose and idx > 0 and idx % 500000 == 0:
          print('  line {}'.format(idx))
        symbols = self.tokenize(line, add_eos=add_eos,
          add_double_eos=add_double_eos)
        encoded.append(self.convert_to_nparray(symbols))

    if ordered:
      encoded = np.concatenate(encoded)

    return encoded 
开发者ID:kimiyoung,项目名称:transformer-xl,代码行数:19,代码来源:vocabulary.py

示例11: main

# 需要导入模块: from tensorflow import gfile [as 别名]
# 或者: from tensorflow.gfile import Exists [as 别名]
def main(unused_argv):
  del unused_argv  # Unused

  corpus = get_lm_corpus(FLAGS.data_dir, FLAGS.dataset)

  save_dir = os.path.join(FLAGS.data_dir, "tfrecords")
  if not exists(save_dir):
    makedirs(save_dir)

  # test mode
  if FLAGS.per_host_test_bsz > 0:
    corpus.convert_to_tfrecords("test", save_dir, FLAGS.per_host_test_bsz,
                                FLAGS.tgt_len, FLAGS.num_core_per_host, 
                                FLAGS=FLAGS)
    return

  for split, batch_size in zip(
      ["train", "valid"],
      [FLAGS.per_host_train_bsz, FLAGS.per_host_valid_bsz]):

    if batch_size <= 0: continue
    print("Converting {} set...".format(split))
    corpus.convert_to_tfrecords(split, save_dir, batch_size, FLAGS.tgt_len,
                                FLAGS.num_core_per_host, FLAGS=FLAGS) 
开发者ID:kimiyoung,项目名称:transformer-xl,代码行数:26,代码来源:data_utils.py

示例12: main

# 需要导入模块: from tensorflow import gfile [as 别名]
# 或者: from tensorflow.gfile import Exists [as 别名]
def main(_argv):
    # load flags from config file
    model_configs = load_from_config_path(FLAGS.config_paths)
    # replace parameters in configs_file with tf FLAGS
    model_configs = update_configs_from_flags(model_configs, FLAGS, TRAIN_ARGS.keys())
    model_dir = model_configs["model_dir"]
    if not gfile.Exists(model_dir):
        gfile.MakeDirs(model_dir)

    if "CUDA_VISIBLE_DEVICES" not in os.environ.keys():
        raise OSError("need CUDA_VISIBLE_DEVICES environment variable")
    tf.logging.info("CUDA_VISIBLE_DEVICES={}".format(os.environ["CUDA_VISIBLE_DEVICES"]))

    training_runner = TrainingExperiment(
        model_configs=model_configs)

    training_runner.run() 
开发者ID:zhaocq-nlp,项目名称:NJUNMT-tf,代码行数:19,代码来源:train.py

示例13: access_multiple_files

# 需要导入模块: from tensorflow import gfile [as 别名]
# 或者: from tensorflow.gfile import Exists [as 别名]
def access_multiple_files(name):
    """ Gets the list of files.

    Args:
        name: A string, the prefix of the files.

    Returns: A list or None.
    """
    assert name
    ret = []
    if gfile.Exists(name):
        ret.append(name)
    else:
        idx = 0
        while gfile.Exists(name + str(idx)):
            ret.append(name + str(idx))
            idx += 1
    assert len(ret) > 0, (
        "Fail to access file {} or {}0...".format(name, name))
    return ret 
开发者ID:zhaocq-nlp,项目名称:NJUNMT-tf,代码行数:22,代码来源:misc.py

示例14: load_from_config_path

# 需要导入模块: from tensorflow import gfile [as 别名]
# 或者: from tensorflow.gfile import Exists [as 别名]
def load_from_config_path(config_paths):
    """ Loads configurations from files of yaml format.

    Args:
        config_paths: A string (each file name is seperated by ",") or
          a list of strings (file names).

    Returns: A dictionary of model configurations, parsed from config files.
    """
    if isinstance(config_paths, six.string_types):
        config_paths = config_paths.strip().split(",")
    assert isinstance(config_paths, list) or isinstance(config_paths, tuple)
    model_configs = dict()
    for config_path in config_paths:
        config_path = config_path.strip()
        if not config_path:
            continue
        if not gfile.Exists(config_path):
            raise OSError("config file does not exist: {}".format(config_path))
        config_path = os.path.abspath(config_path)
        tf.logging.info("loading configurations from {}".format(config_path))
        with open_file(config_path, mode="r") as config_file:
            config_flags = yaml.load(config_file)
            model_configs = deep_merge_dict(model_configs, config_flags)
    return model_configs 
开发者ID:zhaocq-nlp,项目名称:NJUNMT-tf,代码行数:27,代码来源:configurable.py

示例15: get_existing_subvolume_path

# 需要导入模块: from tensorflow import gfile [as 别名]
# 或者: from tensorflow.gfile import Exists [as 别名]
def get_existing_subvolume_path(segmentation_dir, corner, allow_cpoint=False):
  """Returns the path to an existing FFN subvolume.

  This like `get_subvolume_path`, but returns paths to existing data only.

  Args:
    segmentation_dir: directory containing FFN subvolumes
    corner: lower corner of the FFN subvolume as a (z, y, x) tuple
    allow_cpoint: whether to return a checkpoint path in case the final
        segmentation is not ready

  Returns:
    path to an existing FFN subvolume (string) or None if no such subvolume
    is found
  """
  target_path = segmentation_path(segmentation_dir, corner)
  if gfile.Exists(target_path):
    return target_path

  target_path = legacy_segmentation_path(segmentation_dir, corner)
  if gfile.Exists(target_path):
    return target_path

  if allow_cpoint:
    target_path = checkpoint_path(segmentation_dir, corner)
    if gfile.Exists(target_path):
      return target_path

  return None 
开发者ID:google,项目名称:ffn,代码行数:31,代码来源:storage.py


注:本文中的tensorflow.gfile.Exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。