作者|facebookresearch

编译|Flin

来源|Github

detectron2.checkpoint软件包

class detectron2.checkpoint.Checkpointer(model: torch.nn.modules.module.Module, save_dir: str = '', *, save_to_disk: bool = True, **checkpointables)

源代码:https://detectron2.readthedocs.io/_modules/fvcore/common/checkpoint.html#Checkpointer

基类: object

可以保存/加载模型以及其他可检查点对象的检查点。

__init__(model:torch.nn.modules.module.Module,save_dir:str ='',*,save_to_disk:bool = True,** checkpointables )

参数:

model(nn.Module):模型。

save_dir(str):保存和查找检查点的目录。

save_to_disk(bool):如果为True,则将检查点保存到磁盘,否则禁用此检查点的保存。

checkpointables(object):任何可检查点的对象,即具有state_dict()和load_state_dict()方法的对象。例如,它可以像 Checkpointer(model,"dir",optimizer = optimizer)一样使用。

save(name:str,** kwargs )

将模型和检查点转储到文件中。

参数:

name(str):文件名。

kwargs(dict):要保存的额外任意数据。

load(path:str )

从给定的检查点加载。当路径指向网络文件时,必须在所有级别上调用此函数。

参数:

path(str):检查点的路径或url。如果为空,将不会加载任何内容。

返回值: dict ,从检查点加载的尚未处理的额外数据。例如,用save(**extra_data)()保存的内容 。

has_checkpoint()

返回值: bool ,目标目录中是否存在检查点。

get_checkpoint_file()

返回值: str, 目标目录中的最新检查点文件。

get_all_checkpoint_files()

返回值: list,目标中所有可用的检查点文件(.pth文件)目录。

resume_or_load(path:str,*,resume:bool = True )

如果resume为True,则此方法尝试从最后一个检查点(如果存在)恢复。否则,从给定路径加载检查点。重新开始中断的训练作业时,这很有用。

参数:

path(str)–检查点的路径。

resume(bool)–如果为True,则从最后一个检查点恢复(如果存在)。

返回值:和load()一样。

tag_last_checkpoint(last_filename_basename: str)

标记最后一个检查点。

参数: last_filename_basename(str),最后一个文件名的基本名称。

class detectron2.checkpoint.PeriodicCheckpointer(checkpointer: Any, period: int, max_iter: int = None, max_to_keep: int = None)

源代码:https://detectron2.readthedocs.io/_modules/fvcore/common/checkpoint.html#PeriodicCheckpointer

基类: object

定期保存检查点。当 .step(iteration)被调用时,如果迭代是周期的倍数或达到最大值,,它将在给定的checkpointer上执行checkpointer.save。

__init__(checkpointer: Any, period: int, max_iter: int = None, max_to_keep: int = None)

参数:

checkpointer(Any):用于保存的checkpointer对象

checkpoints

period(int):保存检查点的时间段。

max_iter(int):最大迭代次数。到达后,将保存一个名为"model_final"的检查点。

max_to_keep(int):保留的最新当前检查点的最大数量,以前的检查点将被删除

step(iteration: int, **kwargs)

在给定的迭代中执行适当的操作。

参数:

iteration (int)–当前迭代,范围为[0,max_iter-1]。

kwargs(Any)–要保存的额外数据,与Checkpointer.save()中的相同 。

save(name: str, **kwargs)

与相同的论点Checkpointer.save()。使用此方法可以在计划之外手动保存检查点。

参数:

name(str):文件名。

kwargs(Any):要保存的额外数据,与Checkpointer.save()中的相同.

classdetectron2.checkpoint.DetectionCheckpointer(model, save_dir='', *, save_to_disk=None, **checkpointables)

源代码:https://detectron2.readthedocs.io/_modules/detectron2/checkpoint/detection_checkpoint.html#DetectionCheckpointer

基类: fvcore.common.checkpoint.Checkpointer

与Checkpointer相同,但能够处理Detectron和Detectron2模型库中的模型,并将转换应用于旧模型。

原文链接:https://detectron2.readthedocs.io/modules/checkpoint.html

欢迎关注磐创AI博客站:

http://panchuang.net/

sklearn机器学习中文官方文档:

http://sklearn123.com/

欢迎关注磐创博客资源汇总站:

http://docs.panchuang.net/

相关链接

评论可见,请评论后查看内容,谢谢!!!评论后请刷新页面。