本文整理匯總了Python中tensorflow.python.training.training.NewCheckpointReader方法的典型用法代碼示例。如果您正苦於以下問題:Python training.NewCheckpointReader方法的具體用法?Python training.NewCheckpointReader怎麽用?Python training.NewCheckpointReader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tensorflow.python.training.training
的用法示例。
在下文中一共展示了training.NewCheckpointReader方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: load_checkpoint
# 需要導入模塊: from tensorflow.python.training import training [as 別名]
# 或者: from tensorflow.python.training.training import NewCheckpointReader [as 別名]
def load_checkpoint(ckpt_dir_or_file):
"""Returns `CheckpointReader` for checkpoint found in `ckpt_dir_or_file`.
If `ckpt_dir_or_file` resolves to a directory with multiple checkpoints,
reader for the latest checkpoint is returned.
Args:
ckpt_dir_or_file: Directory with checkpoints file or path to checkpoint
file.
Returns:
`CheckpointReader` object.
Raises:
ValueError: If `ckpt_dir_or_file` resolves to a directory with no
checkpoints.
"""
filename = _get_checkpoint_filename(ckpt_dir_or_file)
if filename is None:
raise ValueError("Couldn't find 'checkpoint' file or checkpoints in "
"given directory %s" % ckpt_dir_or_file)
return train.NewCheckpointReader(filename)
示例2: load_checkpoint
# 需要導入模塊: from tensorflow.python.training import training [as 別名]
# 或者: from tensorflow.python.training.training import NewCheckpointReader [as 別名]
def load_checkpoint(filepattern):
"""Returns CheckpointReader for latest checkpoint.
Args:
filepattern: Directory with checkpoints file or path to checkpoint.
Returns:
`CheckpointReader` object.
Raises:
ValueError: if checkpoint_dir doesn't have 'checkpoint' file or checkpoints.
"""
filename = _get_checkpoint_filename(filepattern)
if filename is None:
raise ValueError("Couldn't find 'checkpoint' file or checkpoints in "
"given directory %s" % filepattern)
return train.NewCheckpointReader(filename)
示例3: list_variables
# 需要導入模塊: from tensorflow.python.training import training [as 別名]
# 或者: from tensorflow.python.training.training import NewCheckpointReader [as 別名]
def list_variables(filename):
reader = training.NewCheckpointReader(filename)
variable_map = reader.get_variable_to_shape_map()
names = sorted(variable_map.keys())
return names
示例4: _load_global_step_from_checkpoint_dir
# 需要導入模塊: from tensorflow.python.training import training [as 別名]
# 或者: from tensorflow.python.training.training import NewCheckpointReader [as 別名]
def _load_global_step_from_checkpoint_dir(checkpoint_dir):
try:
checkpoint_reader = training.NewCheckpointReader(
training.latest_checkpoint(checkpoint_dir))
return checkpoint_reader.get_tensor(ops.GraphKeys.GLOBAL_STEP)
except: # pylint: disable=bare-except
return 0
示例5: list_variables
# 需要導入模塊: from tensorflow.python.training import training [as 別名]
# 或者: from tensorflow.python.training.training import NewCheckpointReader [as 別名]
def list_variables(filename):
logger.info(msg="list_variables called")
reader = training.NewCheckpointReader(filename)
variable_map = reader.get_variable_to_shape_map()
names = sorted(variable_map.keys())
return names