本文整理汇总了Python中tensorflow.python.pywrap_tensorflow.TF_DeleteDeprecatedSession方法的典型用法代码示例。如果您正苦于以下问题:Python pywrap_tensorflow.TF_DeleteDeprecatedSession方法的具体用法?Python pywrap_tensorflow.TF_DeleteDeprecatedSession怎么用?Python pywrap_tensorflow.TF_DeleteDeprecatedSession使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensorflow.python.pywrap_tensorflow
的用法示例。
在下文中一共展示了pywrap_tensorflow.TF_DeleteDeprecatedSession方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __del__
# 需要导入模块: from tensorflow.python import pywrap_tensorflow [as 别名]
# 或者: from tensorflow.python.pywrap_tensorflow import TF_DeleteDeprecatedSession [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
示例2: __del__
# 需要导入模块: from tensorflow.python import pywrap_tensorflow [as 别名]
# 或者: from tensorflow.python.pywrap_tensorflow import TF_DeleteDeprecatedSession [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 = c_api_util.ScopedTFStatus()
if self._created_with_new_api:
tf_session.TF_DeleteSession(self._session, status)
else:
tf_session.TF_DeleteDeprecatedSession(self._session, status)
except AttributeError:
# At shutdown, `c_api_util` or `tf_session` may have been garbage
# collected, causing the above method calls to fail. In this case,
# silently leak since the program is about to terminate anyway.
pass
self._session = None
开发者ID:PacktPublishing,项目名称:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代码行数:21,代码来源:session.py
示例3: __del__
# 需要导入模块: from tensorflow.python import pywrap_tensorflow [as 别名]
# 或者: from tensorflow.python.pywrap_tensorflow import TF_DeleteDeprecatedSession [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