使用Slim中的预训练模型训练ssd inception_v3

时间:2018-11-07 04:05:15

标签: python tensorflow

我想使用对象检测API和SLIM(link中的预训练模型来训练ssd inception_v3模型 我尝试使用config训练对象检测ssd inception v3模型:

model {
  ssd {
    num_classes: 1
    image_resizer {
      fixed_shape_resizer {
        height: 240
        width: 320
      }
    }
    feature_extractor {
      type: "ssd_inception_v3"
      depth_multiplier: 1.0
      min_depth: 16
      conv_hyperparams {
        regularizer {
          l2_regularizer {
            weight: 3.99999989895e-05
          }
        }
        initializer {
          truncated_normal_initializer {
            mean: 0.0
            stddev: 0.0299999993294
          }
        }
        activation: RELU_6
        batch_norm {
          decay: 0.999700009823
          center: true
          scale: true
          epsilon: 0.0010000000475
          train: true
        }
      }
      override_base_feature_extractor_hyperparams: true
    }
...

在创建文件model.ckpt-0。*之后,我停止了过程,加载并打印了所有张量的名称。

之后,我使用

https://github.com/tensorflow/models/tree/master/research/slim加载了预训练模型
reader = pywrap_tensorflow.NewCheckpointReader(os.path.join(folder, 'model.ckpt'))
var_to_shape_map = reader.get_variable_to_shape_map()

当我比较输出时,我发现ssd incpetion v3模型没有很多层次。例如:

  

InceptionV3 / AuxLogits / Conv2d_2a_5x5 /权重   InceptionV3 / Mixed_7c / Branch_3 / Conv2d_0b_1x1 / weight

在ssd_inception_v3的模型中,我看到了5c之前的混合层。

SSD_inception和SLIM模型中的功能提取器有什么区别?通常,是否可以从SLIM加载分类器中用于分类器的权重进行检测。

1 个答案:

答案 0 :(得分:1)

您可以看到ssd_inception_v3_feature_extractor中会发生什么。 它使用inception_v3.inception_v3_base(请注意_base)的InceptionV3的'Mixed_5d','Mixed_6e','Mixed_7c'的输出,并创建3个具有512、256、128通道数的附加特征图(此由feature_map_generators.multi_resolution_feature_mapsfeature_map_layout中发生)。 可以通过配置来加载检测模型的分类器权重:

train_config{
    ...
    fine_tune_checkpoint: <path_to_inception_checkpoint>
    fine_tune_checkpoint_type: "classification"
}

当然,检查点必须与您使用的模型匹配,例如ssd_inception_v3

相关问题