本文整理汇总了Python中tensorflow.python.training.summary_io.SummaryWriterCache.get方法的典型用法代码示例。如果您正苦于以下问题:Python SummaryWriterCache.get方法的具体用法?Python SummaryWriterCache.get怎么用?Python SummaryWriterCache.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensorflow.python.training.summary_io.SummaryWriterCache
的用法示例。
在下文中一共展示了SummaryWriterCache.get方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: after_run
# 需要导入模块: from tensorflow.python.training.summary_io import SummaryWriterCache [as 别名]
# 或者: from tensorflow.python.training.summary_io.SummaryWriterCache import get [as 别名]
def after_run(self, run_context, run_values):
results = run_values.results
global_step = results.get('global_step')
if self._draw_images:
self._timer.update_last_triggered_step(global_step)
prediction_dict = results.get('prediction_dict')
if prediction_dict is not None:
summaries = image_vis_summaries(
prediction_dict, config=self._config,
image_visualization_mode=self._image_visualization_mode,
image=results.get('image'),
gt_bboxes=results.get('gt_bboxes')
)
if self._summary_writer is not None:
for summary in summaries:
self._summary_writer.add_summary(summary, global_step)
self._next_step = global_step + 1
示例2: __init__
# 需要导入模块: from tensorflow.python.training.summary_io import SummaryWriterCache [as 别名]
# 或者: from tensorflow.python.training.summary_io.SummaryWriterCache import get [as 别名]
def __init__(self,
every_n_steps=100,
every_n_secs=None,
output_dir=None,
summary_writer=None):
self._summary_tag = "global_step/sec"
if (every_n_steps is None) == (every_n_secs is None):
raise ValueError(
"exactly one of every_n_steps and every_n_secs should be provided.")
self._timer = _SecondOrStepTimer(every_steps=every_n_steps,
every_secs=every_n_secs)
self._summary_writer = summary_writer
if summary_writer is None and output_dir:
self._summary_writer = SummaryWriterCache.get(output_dir)
示例3: after_run
# 需要导入模块: from tensorflow.python.training.summary_io import SummaryWriterCache [as 别名]
# 或者: from tensorflow.python.training.summary_io.SummaryWriterCache import get [as 别名]
def after_run(self, run_context, run_values):
_ = run_context
stale_global_step = run_values.results
if self._timer.should_trigger_for_step(stale_global_step+1):
# get the real value after train op.
global_step = run_context.session.run(self._global_step_tensor)
if self._timer.should_trigger_for_step(global_step):
elapsed_time, elapsed_steps = self._timer.update_last_triggered_step(
global_step)
if elapsed_time is not None:
steps_per_sec = elapsed_steps / elapsed_time
if self._summary_writer is not None:
summary = Summary(value=[Summary.Value(
tag=self._summary_tag, simple_value=steps_per_sec)])
self._summary_writer.add_summary(summary, global_step)
logging.info("%s: %g", self._summary_tag, steps_per_sec)
开发者ID:PacktPublishing,项目名称:Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda,代码行数:19,代码来源:basic_session_run_hooks.py
示例4: __init__
# 需要导入模块: from tensorflow.python.training.summary_io import SummaryWriterCache [as 别名]
# 或者: from tensorflow.python.training.summary_io.SummaryWriterCache import get [as 别名]
def __init__(self,
checkpoint_dir,
save_secs=None,
save_steps=None,
saver=None,
checkpoint_basename="model.ckpt",
scaffold=None,
listeners=None):
"""Initializes a `CheckpointSaverHook`.
Args:
checkpoint_dir: `str`, base directory for the checkpoint files.
save_secs: `int`, save every N secs.
save_steps: `int`, save every N steps.
saver: `Saver` object, used for saving.
checkpoint_basename: `str`, base name for the checkpoint files.
scaffold: `Scaffold`, use to get saver object.
listeners: List of `CheckpointSaverListener` subclass instances.
Used for callbacks that run immediately before or after this hook saves
the checkpoint.
Raises:
ValueError: One of `save_steps` or `save_secs` should be set.
ValueError: Exactly one of saver or scaffold should be set.
"""
logging.info("Create CheckpointSaverHook.")
if saver is not None and scaffold is not None:
raise ValueError("You cannot provide both saver and scaffold.")
if saver is None and scaffold is None:
saver = saver_lib._get_saver_or_default() # pylint: disable=protected-access
self._saver = saver
self._checkpoint_dir = checkpoint_dir
self._save_path = os.path.join(checkpoint_dir, checkpoint_basename)
self._scaffold = scaffold
self._timer = SecondOrStepTimer(every_secs=save_secs,
every_steps=save_steps)
self._listeners = listeners or []
示例5: begin
# 需要导入模块: from tensorflow.python.training.summary_io import SummaryWriterCache [as 别名]
# 或者: from tensorflow.python.training.summary_io.SummaryWriterCache import get [as 别名]
def begin(self):
self._summary_writer = SummaryWriterCache.get(self._checkpoint_dir)
self._global_step_tensor = training_util.get_global_step()
if self._global_step_tensor is None:
raise RuntimeError(
"Global step should be created to use CheckpointSaverHook.")
for l in self._listeners:
l.begin()
示例6: __init__
# 需要导入模块: from tensorflow.python.training.summary_io import SummaryWriterCache [as 别名]
# 或者: from tensorflow.python.training.summary_io.SummaryWriterCache import get [as 别名]
def __init__(self,
checkpoint_dir,
save_secs=None,
save_steps=None,
saver=None,
checkpoint_basename="model.ckpt",
scaffold=None,
listeners=None):
"""Initialize CheckpointSaverHook monitor.
Args:
checkpoint_dir: `str`, base directory for the checkpoint files.
save_secs: `int`, save every N secs.
save_steps: `int`, save every N steps.
saver: `Saver` object, used for saving.
checkpoint_basename: `str`, base name for the checkpoint files.
scaffold: `Scaffold`, use to get saver object.
listeners: List of `CheckpointSaverListener` subclass instances.
Used for callbacks that run immediately after the corresponding
CheckpointSaverHook callbacks, only in steps where the
CheckpointSaverHook was triggered.
Raises:
ValueError: One of `save_steps` or `save_secs` should be set.
ValueError: Exactly one of saver or scaffold should be set.
"""
logging.info("Create CheckpointSaverHook.")
if ((saver is None and scaffold is None) or
(saver is not None and scaffold is not None)):
raise ValueError("Exactly one of saver or scaffold must be provided.")
self._saver = saver
self._checkpoint_dir = checkpoint_dir
self._save_path = os.path.join(checkpoint_dir, checkpoint_basename)
self._scaffold = scaffold
self._timer = SecondOrStepTimer(every_secs=save_secs,
every_steps=save_steps)
self._listeners = listeners or []
示例7: visualize_embeddings
# 需要导入模块: from tensorflow.python.training.summary_io import SummaryWriterCache [as 别名]
# 或者: from tensorflow.python.training.summary_io.SummaryWriterCache import get [as 别名]
def visualize_embeddings(logdir, var_list, tsv_list):
assert len(var_list) == len(tsv_list), 'Inconsistent length of lists'
config = projector.ProjectorConfig()
for v, f in zip(var_list, tsv_list):
embedding = config.embeddings.add()
embedding.tensor_name = v.name
if f is not None:
_, filename = os.path.split(f)
meta_tsv = os.path.join(logdir, filename)
tf.gfile.Copy(f, meta_tsv)
embedding.metadata_path = filename # save relative path
writer = SummaryWriterCache.get(logdir)
projector.visualize_embeddings(writer, config)
示例8: get_inference_input
# 需要导入模块: from tensorflow.python.training.summary_io import SummaryWriterCache [as 别名]
# 或者: from tensorflow.python.training.summary_io.SummaryWriterCache import get [as 别名]
def get_inference_input():
"""Set up placeholders for input features/labels.
Returns the feature, output tensors that get passed into model_fn."""
return (tf.placeholder(tf.float32,
[None, go.N, go.N, features.NEW_FEATURES_PLANES],
name='pos_tensor'),
{'pi_tensor': tf.placeholder(tf.float32, [None, go.N * go.N + 1]),
'value_tensor': tf.placeholder(tf.float32, [None])})
示例9: begin
# 需要导入模块: from tensorflow.python.training.summary_io import SummaryWriterCache [as 别名]
# 或者: from tensorflow.python.training.summary_io.SummaryWriterCache import get [as 别名]
def begin(self):
# These calls only works because the SessionRunHook api guarantees this
# will get called within a graph context containing our model graph.
self.summary_writer = SummaryWriterCache.get(self.working_dir)
self.weight_tensors = tf.trainable_variables()
self.global_step = tf.train.get_or_create_global_step()
示例10: __init__
# 需要导入模块: from tensorflow.python.training.summary_io import SummaryWriterCache [as 别名]
# 或者: from tensorflow.python.training.summary_io.SummaryWriterCache import get [as 别名]
def __init__(self,
checkpoint_dir,
save_secs=None,
save_steps=None,
saver=None,
checkpoint_basename="model.ckpt",
scaffold=None,
listeners=None):
"""Initializes a `CheckpointSaverHook`.
Args:
checkpoint_dir: `str`, base directory for the checkpoint files.
save_secs: `int`, save every N secs.
save_steps: `int`, save every N steps.
saver: `Saver` object, used for saving.
checkpoint_basename: `str`, base name for the checkpoint files.
scaffold: `Scaffold`, use to get saver object.
listeners: List of `CheckpointSaverListener` subclass instances. Used for
callbacks that run immediately before or after this hook saves the
checkpoint.
Raises:
ValueError: One of `save_steps` or `save_secs` should be set.
ValueError: At most one of `saver` or `scaffold` should be set.
"""
logging.info("Create AsyncCheckpointSaverHook.")
if saver is not None and scaffold is not None:
raise ValueError("You cannot provide both saver and scaffold.")
self._saver = saver
self._save_thread = None
self._write_graph_thread = None
self._checkpoint_dir = checkpoint_dir
self._save_path = os.path.join(checkpoint_dir, checkpoint_basename)
self._scaffold = scaffold
self._timer = basic_session_run_hooks.SecondOrStepTimer(
every_secs=save_secs, every_steps=save_steps)
self._listeners = listeners or []
self._steps_per_run = 1
self._summary_writer = None
self._global_step_tensor = None
示例11: begin
# 需要导入模块: from tensorflow.python.training.summary_io import SummaryWriterCache [as 别名]
# 或者: from tensorflow.python.training.summary_io.SummaryWriterCache import get [as 别名]
def begin(self):
self._summary_writer = SummaryWriterCache.get(self._checkpoint_dir)
self._global_step_tensor = training_util._get_or_create_global_step_read() # pylint: disable=protected-access
if self._global_step_tensor is None:
raise RuntimeError(
"Global step should be created to use CheckpointSaverHook.")
for l in self._listeners:
l.begin()