本文整理匯總了Python中tensorpack.dataflow.base.DataFlowTerminated方法的典型用法代碼示例。如果您正苦於以下問題:Python base.DataFlowTerminated方法的具體用法?Python base.DataFlowTerminated怎麽用?Python base.DataFlowTerminated使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tensorpack.dataflow.base
的用法示例。
在下文中一共展示了base.DataFlowTerminated方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run
# 需要導入模塊: from tensorpack.dataflow import base [as 別名]
# 或者: from tensorpack.dataflow.base import DataFlowTerminated [as 別名]
def run(self):
with self.default_sess():
try:
while not self._coord.should_stop():
try:
self.ds.reset_state()
while True:
for dp in self.ds.get_data():
feed = dict(zip(self.placeholders, dp))
self.op.run(feed_dict=feed)
except (tf.errors.CancelledError, tf.errors.OutOfRangeError, DataFlowTerminated):
pass
except Exception as e:
if isinstance(e, RuntimeError) and 'closed Session' in str(e):
pass
else:
logging.exception("Exception in {}:{}".format(self.name, str(e)))
except Exception as e:
logging.exception("Exception in {}:{}".format(self.name, str(e)))
finally:
try:
self.close_op.run()
except Exception:
pass
logging.info("{} Exited.".format(self.name))
示例2: run
# 需要導入模塊: from tensorpack.dataflow import base [as 別名]
# 或者: from tensorpack.dataflow.base import DataFlowTerminated [as 別名]
def run(self):
with self.default_sess():
try:
while not self._coord.should_stop():
try:
self.ds.reset_state()
while True:
for dp in self.ds.get_data():
feed = dict(zip(self.placeholders, dp))
self.op.run(feed_dict=feed)
self.last_dp = dp
except (tf.errors.CancelledError, tf.errors.OutOfRangeError, DataFlowTerminated):
logger.error('err type1, placeholders={}'.format(self.placeholders))
sys.exit(-1)
except Exception as e:
logger.error('err type2, err={}, placeholders={}'.format(str(e), self.placeholders))
if isinstance(e, RuntimeError) and 'closed Session' in str(e):
pass
else:
logger.exception("Exception in {}:{}".format(self.name, str(e)))
sys.exit(-1)
except Exception as e:
logger.exception("Exception in {}:{}".format(self.name, str(e)))
finally:
try:
self.close_op.run()
except Exception:
pass
logger.info("{} Exited.".format(self.name))