Detectron2系列之模型训练

从前面的教程中,你现在已经有了一个自定义的模型和数据加载器。
你可以*创建自己的优化器,并编写训练逻辑:可以使用PyTorch使研究人员对整个训练逻辑更清晰并具有完全控制权。tools/plain_train_net.py中提供了一个这样的示例。(tools/plain_train_net.py:https://github.com/facebookresearch/detectron2/blob/master/tools/plain_train_net.py)
我们还提供了标准化的"trainer"抽象,最小hook系统(https://detectron2.readthedocs.io/modules/engine.html#detectron2.engine.HookBase) ,这有助于简化标准的训练类型。
你可以使用 SimpleTrainer().train() ,它为单次成本、单优化器、单数据源的训练提供了最小的抽象。内置train_net.py脚本使用 DefaultTrainer().train(),它包含一个人们可能希望选择的更多标准默认行为,这也意味着它不太可能支持你在研究过程中可能想要的一些非标准行为。


from detectron2.utils.events import get_event_storage# 在模型中:if self.training:  value = #根据输入计算值  storage = get_event_storage()  storage.put_scalar("some_accuracy", value)

有关更多详细信息,请参阅其文档。
原文链接:https://detectron2.readthedocs.io/tutorials/training.html

上一篇:Detectron2系列:detectron2更改日志


下一篇:FAIR开源框架detectron2代码解析