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


Python pywrap_tensorflow.TF_NewStatus方法代碼示例

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


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

示例1: __del__

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import TF_NewStatus [as 別名]
def __del__(self):
    # cleanly ignore all exceptions
    try:
      self.close()
    except Exception:  # pylint: disable=broad-except
      pass
    if self._session is not None:
      # We create `status` outside the `try` block because at shutdown
      # `tf_session` may have been garbage collected, and the creation
      # of a status object may fail. In that case, we prefer to ignore
      # the failure and silently leak the session object, since the
      # program is about to terminate.
      status = None
      try:
        status = tf_session.TF_NewStatus()
        tf_session.TF_DeleteDeprecatedSession(self._session, status)
      except AttributeError:
        # 'NoneType' object has no attribute 'TF_NewStatus'
        pass
      finally:
        if status is not None:
          tf_session.TF_DeleteStatus(status)
      self._session = None 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:25,代碼來源:session.py

示例2: is_directory

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import TF_NewStatus [as 別名]
def is_directory(dirname):
  """Returns whether the path is a directory or not.

  Args:
    dirname: string, path to a potential directory

  Returns:
    True, if the path is a directory; False otherwise
  """
  try:
    status = pywrap_tensorflow.TF_NewStatus()
    return pywrap_tensorflow.IsDirectory(compat.as_bytes(dirname), status)
  finally:
    pywrap_tensorflow.TF_DeleteStatus(status) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:16,代碼來源:file_io.py

示例3: raise_exception_on_not_ok_status

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import TF_NewStatus [as 別名]
def raise_exception_on_not_ok_status():
  status = pywrap_tensorflow.TF_NewStatus()
  try:
    yield status
    if pywrap_tensorflow.TF_GetCode(status) != 0:
      raise _make_specific_exception(
          None, None,
          compat.as_text(pywrap_tensorflow.TF_Message(status)),
          pywrap_tensorflow.TF_GetCode(status))
  finally:
    pywrap_tensorflow.TF_DeleteStatus(status) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:13,代碼來源:errors_impl.py

示例4: load_file_system_library

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import TF_NewStatus [as 別名]
def load_file_system_library(library_filename):
  """Loads a TensorFlow plugin, containing file system implementation.

  Pass `library_filename` to a platform-specific mechanism for dynamically
  loading a library. The rules for determining the exact location of the
  library are platform-specific and are not documented here.

  Args:
    library_filename: Path to the plugin.
      Relative or absolute filesystem path to a dynamic library file.

  Returns:
    None.

  Raises:
    RuntimeError: when unable to load the library.
  """
  status = py_tf.TF_NewStatus()
  lib_handle = py_tf.TF_LoadLibrary(library_filename, status)
  try:
    error_code = py_tf.TF_GetCode(status)
    if error_code != 0:
      error_msg = compat.as_text(py_tf.TF_Message(status))
      # pylint: disable=protected-access
      raise errors_impl._make_specific_exception(
          None, None, error_msg, error_code)
      # pylint: enable=protected-access
  finally:
    py_tf.TF_DeleteStatus(status) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:31,代碼來源:load_library.py

示例5: __del__

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import TF_NewStatus [as 別名]
def __del__(self):
    # cleanly ignore all exceptions
    try:
      self.close()
    except Exception:  # pylint: disable=broad-except
      pass
    if self._session is not None:
      try:
        status = tf_session.TF_NewStatus()
        tf_session.TF_DeleteDeprecatedSession(self._session, status)
      finally:
        tf_session.TF_DeleteStatus(status)
      self._session = None 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:15,代碼來源:session.py

示例6: raise_exception_on_not_ok_status

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import TF_NewStatus [as 別名]
def raise_exception_on_not_ok_status():
  try:
    status = pywrap_tensorflow.TF_NewStatus()
    yield status
    if pywrap_tensorflow.TF_GetCode(status) != 0:
      raise _make_specific_exception(
          None, None,
          compat.as_text(pywrap_tensorflow.TF_Message(status)),
          pywrap_tensorflow.TF_GetCode(status))
  finally:
    pywrap_tensorflow.TF_DeleteStatus(status) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:13,代碼來源:errors_impl.py

示例7: __init__

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import TF_NewStatus [as 別名]
def __init__(self):
    self.status = c_api.TF_NewStatus() 
開發者ID:PacktPublishing,項目名稱:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代碼行數:4,代碼來源:c_api_util.py

示例8: load_op_library

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import TF_NewStatus [as 別名]
def load_op_library(library_filename):
  """Loads a TensorFlow plugin, containing custom ops and kernels.

  Pass "library_filename" to a platform-specific mechanism for dynamically
  loading a library. The rules for determining the exact location of the
  library are platform-specific and are not documented here. When the
  library is loaded, ops and kernels registered in the library via the
  `REGISTER_*` macros are made available in the TensorFlow process. Note
  that ops with the same name as an existing op are rejected and not
  registered with the process.

  Args:
    library_filename: Path to the plugin.
      Relative or absolute filesystem path to a dynamic library file.

  Returns:
    A python module containing the Python wrappers for Ops defined in
    the plugin.

  Raises:
    RuntimeError: when unable to load the library or get the python wrappers.
  """
  status = py_tf.TF_NewStatus()

  lib_handle = py_tf.TF_LoadLibrary(library_filename, status)
  try:
    error_code = py_tf.TF_GetCode(status)
    if error_code != 0:
      error_msg = compat.as_text(py_tf.TF_Message(status))
      # pylint: disable=protected-access
      raise errors_impl._make_specific_exception(
          None, None, error_msg, error_code)
      # pylint: enable=protected-access
  finally:
    py_tf.TF_DeleteStatus(status)

  op_list_str = py_tf.TF_GetOpList(lib_handle)
  op_list = op_def_pb2.OpList()
  op_list.ParseFromString(compat.as_bytes(op_list_str))
  wrappers = py_tf.GetPythonWrappers(op_list_str)

  # Delete the library handle to release any memory held in C
  # that are no longer needed.
  py_tf.TF_DeleteLibraryHandle(lib_handle)

  # Get a unique name for the module.
  module_name = hashlib.md5(wrappers).hexdigest()
  if module_name in sys.modules:
    return sys.modules[module_name]
  module = imp.new_module(module_name)
  # pylint: disable=exec-used
  exec(wrappers, module.__dict__)
  # Stash away the library handle for making calls into the dynamic library.
  module.LIB_HANDLE = lib_handle
  # OpDefs of the list of ops defined in the library.
  module.OP_LIST = op_list
  sys.modules[module_name] = module
  return module 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:60,代碼來源:load_library.py

示例9: load_op_library

# 需要導入模塊: from tensorflow.python import pywrap_tensorflow [as 別名]
# 或者: from tensorflow.python.pywrap_tensorflow import TF_NewStatus [as 別名]
def load_op_library(library_filename):
  """Loads a TensorFlow plugin, containing custom ops and kernels.

  Pass "library_filename" to a platform-specific mechanism for dynamically
  loading a library. The rules for determining the exact location of the
  library are platform-specific and are not documented here. When the
  library is loaded, ops and kernels registered in the library via the
  `REGISTER_*` macros are made available in the TensorFlow process. Note
  that ops with the same name as an existing op are rejected and not
  registered with the process.

  Args:
    library_filename: Path to the plugin.
      Relative or absolute filesystem path to a dynamic library file.

  Returns:
    A python module containing the Python wrappers for Ops defined in
    the plugin.

  Raises:
    RuntimeError: when unable to load the library or get the python wrappers.
  """
  status = py_tf.TF_NewStatus()

  lib_handle = py_tf.TF_LoadLibrary(library_filename, status)
  try:
    error_code = py_tf.TF_GetCode(status)
    if error_code != 0:
      error_msg = compat.as_text(py_tf.TF_Message(status))
      # pylint: disable=protected-access
      raise errors_impl._make_specific_exception(
          None, None, error_msg, error_code)
      # pylint: enable=protected-access
  finally:
    py_tf.TF_DeleteStatus(status)

  op_list_str = py_tf.TF_GetOpList(lib_handle)
  op_list = op_def_pb2.OpList()
  op_list.ParseFromString(compat.as_bytes(op_list_str))
  wrappers = py_tf.GetPythonWrappers(op_list_str)

  # Get a unique name for the module.
  module_name = hashlib.md5(wrappers).hexdigest()
  if module_name in sys.modules:
    return sys.modules[module_name]
  module = imp.new_module(module_name)
  # pylint: disable=exec-used
  exec(wrappers, module.__dict__)
  # Stash away the library handle for making calls into the dynamic library.
  module.LIB_HANDLE = lib_handle
  # OpDefs of the list of ops defined in the library.
  module.OP_LIST = op_list
  sys.modules[module_name] = module
  return module 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:56,代碼來源:load_library.py


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