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


Python errors_impl.NotFoundError方法代码示例

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


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

示例1: RetrieveAsset

# 需要导入模块: from tensorflow.python.framework import errors_impl [as 别名]
# 或者: from tensorflow.python.framework.errors_impl import NotFoundError [as 别名]
def RetrieveAsset(logdir, plugin_name, asset_name):
  """Retrieve a particular plugin asset from a logdir.

  Args:
    logdir: A directory that was created by a TensorFlow summary.FileWriter.
    plugin_name: The plugin we want an asset from.
    asset_name: The name of the requested asset.

  Returns:
    string contents of the plugin asset.

  Raises:
    KeyError: if the asset does not exist.
  """

  asset_path = os.path.join(PluginDirectory(logdir, plugin_name), asset_name)
  try:
    with gfile.Open(asset_path, "r") as f:
      return f.read()
  except errors_impl.NotFoundError:
    raise KeyError("Asset path %s not found" % asset_path)
  except errors_impl.OpError as e:
    raise KeyError("Couldn't read asset path: %s, OpError %s" % (asset_path, e)) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:25,代码来源:plugin_asset_util.py

示例2: garbage_collect_exports

# 需要导入模块: from tensorflow.python.framework import errors_impl [as 别名]
# 或者: from tensorflow.python.framework.errors_impl import NotFoundError [as 别名]
def garbage_collect_exports(export_dir_base, exports_to_keep):
  """Deletes older exports, retaining only a given number of the most recent.

  Export subdirectories are assumed to be named with monotonically increasing
  integers; the most recent are taken to be those with the largest values.

  Args:
    export_dir_base: the base directory under which each export is in a
      versioned subdirectory.
    exports_to_keep: the number of recent exports to retain.
  """
  if exports_to_keep is None:
    return

  keep_filter = gc.largest_export_versions(exports_to_keep)
  delete_filter = gc.negation(keep_filter)
  for p in delete_filter(gc.get_paths(export_dir_base,
                                      parser=_export_version_parser)):
    try:
      gfile.DeleteRecursively(p.path)
    except errors_impl.NotFoundError as e:
      logging.warn('Can not delete %s recursively: %s', p.path, e) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:24,代码来源:saved_model_export_utils.py

示例3: get_maxiter_weights

# 需要导入模块: from tensorflow.python.framework import errors_impl [as 别名]
# 或者: from tensorflow.python.framework.errors_impl import NotFoundError [as 别名]
def get_maxiter_weights(dir):
    try:
        filenames = gfile.Glob(dir + '/model*')
    except NotFoundError:
        print('nothing found at ', dir + '/model*')
        return None
    iternums = []
    if len(filenames) != 0:
        for f in filenames:
            try:
                iternums.append(int(re.match('.*?([0-9]+)$', f).group(1)))
            except:
                iternums.append(-1)
        iternums = np.array(iternums)
        return filenames[np.argmax(iternums)].split('.')[0]  # skip the str after the '.'
    else:
        return None 
开发者ID:SudeepDasari,项目名称:visual_foresight,代码行数:19,代码来源:setup_predictor.py

示例4: testNotFoundError

# 需要导入模块: from tensorflow.python.framework import errors_impl [as 别名]
# 或者: from tensorflow.python.framework.errors_impl import NotFoundError [as 别名]
def testNotFoundError(self):
    model_dir = tempfile.mkdtemp('not_found_error')
    if gfile.Exists(model_dir):
      gfile.DeleteRecursively(model_dir)

    init_value0 = 10.0
    init_value1 = 20.0
    var_names_to_values = {'v0': init_value0, 'v1': init_value1}

    with self.cached_session() as sess:
      model_path = self.create_checkpoint_from_values(var_names_to_values,
                                                      model_dir)
      var0 = variables_lib2.variable('my_var0', shape=[])
      var1 = variables_lib2.variable('my_var1', shape=[])
      var2 = variables_lib2.variable('my_var2', shape=[])

      vars_to_restore = {'v0': var0, 'v1': var1, 'v2': var2}
      init_fn = variables_lib2.assign_from_checkpoint_fn(
          model_path, vars_to_restore)

      # Initialize the variables.
      sess.run(variables_lib.global_variables_initializer())

      # Perform the assignment.
      with self.assertRaises(errors_impl.NotFoundError):
        init_fn(sess) 
开发者ID:google-research,项目名称:tf-slim,代码行数:28,代码来源:variables_test.py

示例5: _garbage_collect_exports

# 需要导入模块: from tensorflow.python.framework import errors_impl [as 别名]
# 或者: from tensorflow.python.framework.errors_impl import NotFoundError [as 别名]
def _garbage_collect_exports(self, export_dir_base: Text):
    """Deletes older exports, retaining only a given number of the most recent.

    Export subdirectories are assumed to be named with monotonically increasing
    integers; the most recent are taken to be those with the largest values.

    Args:
      export_dir_base: the base directory under which each export is in a
        versioned subdirectory.
    """
    if self._exports_to_keep is None:
      return

    def _export_version_parser(path):
      # create a simple parser that pulls the export_version from the directory.
      filename = os.path.basename(path.path)
      if not (len(filename) == 10 and filename.isdigit()):
        return None
      return path._replace(export_version=int(filename))

    # pylint: disable=protected-access
    keep_filter = gc._largest_export_versions(self._exports_to_keep)
    delete_filter = gc._negation(keep_filter)
    for p in delete_filter(
        gc._get_paths(export_dir_base, parser=_export_version_parser)):
      try:
        gfile.DeleteRecursively(p.path)
      except errors_impl.NotFoundError as e:
        tf_logging.warn('Can not delete %s recursively: %s', p.path, e)
    # pylint: enable=protected-access 
开发者ID:tensorflow,项目名称:model-analysis,代码行数:32,代码来源:exporter.py

示例6: _garbage_collect_exports

# 需要导入模块: from tensorflow.python.framework import errors_impl [as 别名]
# 或者: from tensorflow.python.framework.errors_impl import NotFoundError [as 别名]
def _garbage_collect_exports(self, export_dir_base):
    """Deletes older exports, retaining only a given number of the most recent.

    Export subdirectories are assumed to be named with monotonically increasing
    integers; the most recent are taken to be those with the largest values.

    Args:
      export_dir_base: the base directory under which each export is in a
        versioned subdirectory.
    """
    if self._exports_to_keep is None:
      return

    def _export_version_parser(path):
      # create a simple parser that pulls the export_version from the directory.
      filename = os.path.basename(path.path)
      if not (len(filename) == 10 and filename.isdigit()):
        return None
      return path._replace(export_version=int(filename))

    # pylint: disable=protected-access
    keep_filter = gc._largest_export_versions(self._exports_to_keep)
    delete_filter = gc._negation(keep_filter)
    for p in delete_filter(
        gc._get_paths(export_dir_base, parser=_export_version_parser)):
      try:
        gfile.DeleteRecursively(p.path)
      except errors_impl.NotFoundError as e:
        tf_logging.warn('Can not delete %s recursively: %s', p.path, e)
    # pylint: enable=protected-access 
开发者ID:PacktPublishing,项目名称:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代码行数:32,代码来源:exporter.py


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