本文整理汇总了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