Tensorflow对象检测:继续训练



假设我训练了一个像ResNet这样的预训练网络,并将其设置为在pipeline.config file中检测fine_tune_checkpoint_type属性。据我所知,这意味着我们取模型的预训练权重,除了分类和盒预测头。此外,这意味着我们可以创建我们自己的标签类型,然后这些标签将作为我们想要创建/训练的模型的分类和框预测头。

现在,假设我训练这个网络25000步,并希望在模型不忘记任何东西的情况下继续训练。我是否应该将pipeline.config中的fine_tune_checkpoint_type更改为full以继续训练(当然还要加载正确的检查点文件),或者我是否仍然应该将其设置为detection?

编辑:

这是基于这里找到的信息https://github.com/tensorflow/models/blob/master/research/object_detection/protos/train.proto:

//   1. "classification": Restores only the classification backbone part of
//        the feature extractor. This option is typically used when you want
//        to train a detection model starting from a pre-trained image
//        classification model, e.g. a ResNet model pre-trained on ImageNet.
//   2. "detection": Restores the entire feature extractor. The only parts
//        of the full detection model that are not restored are the box and
//        class prediction heads. This option is typically used when you want
//        to use a pre-trained detection model and train on a new dataset or
//        task which requires different box and class prediction heads.
//   3. "full": Restores the entire detection model, including the
//        feature extractor, its classification backbone, and the prediction
//        heads. This option should only be used when the pre-training and
//        fine-tuning tasks are the same. Otherwise, the model's parameters
//        may have incompatible shapes, which will cause errors when
//        attempting to restore the checkpoint.

因此,classification只提供了特征提取器的分类骨干部分。这意味着该模型将在网络的许多部分从头开始。

detection恢复整个特征提取器,但"最终结果"。将被遗忘,这意味着我们可以添加自己的类,并从头开始学习这些分类。

full恢复所有内容,甚至包括类和盒预测权重。但是,只要我们不添加或删除任何类/标签,这是可以的。

正确吗?

是的,你理解对了。
piepline.config中设置fine_tune_checkpoint_type: full以保留所有模型所学到的直到最后一个检查点。

是的,您可以通过设置fine_tune_checkpoint_type来配置要恢复的变量,选项是检测和分类。通过将其设置为检测,基本上你可以从检查点恢复几乎所有的变量,通过将其设置为分类,只有来自feature_extractor作用域的变量被恢复(骨干网络中的所有层,如VGG, Resnet, MobileNet,它们被称为特征提取器)。

点击这里查看更多信息。

最新更新