首页 > 解决方案 > 警告:变量在检查点中不可用

问题描述

我正在为 MobileNetV1 训练 FasterRCNN。

这个模型zoos 没有针对 MobileNetV1 的 FasterRCNN 的预训练模型。

所以我从这里使用了预训练模型。

但是我有错误,因为检查点中没有变量。相当多的警告,我展示了其中的一些。这些是警告,但训练仍然可以在没有预训练权重的情况下进行。

我的问题是为什么我不能使用 FasterRCNN 的这些预训练权重。

在本教程中,它在中间被称为"We typically initialize the weights of this feature extractor using those from the Slim Resnet-101 classification checkpoint, and we know that images were preprocessed when training this checkpoint by subtracting a channel mean from each input image. Thus, we implement the preprocess function to replicate the same channel mean subtraction behavior."

为什么我不能使用这些重量?

我在配置文件中加载预训练模型

fine_tune_checkpoint: "object_detection/data/mobilenet_v1_1.0_224/mobilenet_v1_1.0_224.ckpt"
from_detection_checkpoint: true

警告是

WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_0/BatchNorm/beta] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_0/BatchNorm/gamma] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_0/BatchNorm/moving_mean] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_0/BatchNorm/moving_variance] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_0/weights] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_10_depthwise/BatchNorm/beta] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_10_depthwise/BatchNorm/gamma] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_10_depthwise/BatchNorm/moving_mean] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_10_depthwise/BatchNorm/moving_variance] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_10_depthwise/depthwise_weights] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_10_pointwise/BatchNorm/beta] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_10_pointwise/BatchNorm/gamma] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_10_pointwise/BatchNorm/moving_mean] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_10_pointwise/BatchNorm/moving_variance] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_10_pointwise/weights] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_11_depthwise/BatchNorm/beta] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_11_depthwise/BatchNorm/gamma] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_11_depthwise/BatchNorm/moving_mean] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_11_depthwise/BatchNorm/moving_variance] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_11_depthwise/depthwise_weights] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_11_pointwise/BatchNorm/beta] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_11_pointwise/BatchNorm/gamma] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_11_pointwise/BatchNorm/moving_mean] is not available in checkpoint
WARNING:root:Variable [FirstStageFeatureExtractor/MobilenetV1/Conv2d_11_pointwise/BatchNorm/moving_variance] is not available in checkpoint

标签: pythontensorflowobject-detection-api

解决方案


是的,可以使用此处的预训练模型。可以从 variable_names_map 中检查初始化需要哪些变量以及从加载的检查点获得哪些变量。从那里,选择变量并初始化以进一步微调。

需要对 Tensorflow 的代码进行一些修改,主要在 utils/variables_helper.py 文件中。

FasterRCNN 的 FirstStage 和 SecondStage 中的内容由 faster_rcnn_mobilenet_v1_feature_extractor.py 决定


推荐阅读