使用 Tensorflow 2 对象检测 API 冻结了哪些层?

Posted

技术标签:

【中文标题】使用 Tensorflow 2 对象检测 API 冻结了哪些层?【英文标题】:Which layers are frozen using Tensorflow 2 Object detection API? 【发布时间】:2021-12-18 16:26:52 【问题描述】:

如何从 Tensorflow Model Zoo 2 中了解哪些层被冻结微调检测模型? 我已经成功设置了 Fine_tune_checkpoint 和 fine_tune_checkpoint_type: detection 的路径,并且在文件 proto 中我已经阅读了“检测”的意思

// 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.

我真的不明白这是什么意思。在这种情况下,恢复意味着冻结?

【问题讨论】:

【参考方案1】:

据我了解,目前 Tensorflow 2 对象检测在从微调检查点进行训练时不会冻结任何层。报告了一个问题 here 以支持在管道配置中指定要冻结的层。如果您查看training step function,您可以看到在训练期间应用梯度时使用了所有可训练变量。

这里的恢复意味着模型权重是从检查点复制过来的,作为训练的起点。冻结意味着在训练期间权重没有改变(即没有应用梯度)。

【讨论】:

好的,你知道在这种情况下哪些层必须被冻结吗?我想对两个微调模型的新类进行对象检测,但我没有很多数据。 我应该提到,管道配置确实支持冻结批量标准化层,这显然是微调的常见做法。没有层必须被冻结。我建议在对象检测 API 示例中查看此 example project。在该示例中,作者恢复了比主要对象检测包中更多的检查点,并且还选择在训练中冻结大多数层。 是的,我读到微调不需要冻结任何层,但它只是利用在更大数据集上初始化的权重和配置,ty。

以上是关于使用 Tensorflow 2 对象检测 API 冻结了哪些层?的主要内容,如果未能解决你的问题,请参考以下文章

如何从代码运行 tensorflow 对象检测 api (model_main_tf2)?

Tensorflow 2 对象检测 API:Numpy 版本错误

为啥来自 Tensorflow 2 对象检测 API 的微调模型上的 mAP 较低?

如何解决 Tensorflow 2 对象检测 API 中的 UnicodeError

Tensorflow v1 对象检测 api mask_rcnn_inception_v2_coco 模型批量推理

TensorFlow 对象检测 API 中未检测到任何内容