當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。