微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

inception_v2.py 文件中的 include_root_block 解释是什么?

如何解决inception_v2.py 文件中的 include_root_block 解释是什么?

我一直在使用 inception_v2 模块学习 Faster R-CNN。我一直在努力了解架构是如何运作的。这就是 inception_v2 架构的样子:

Inception_v2 module architecture

据我所知,Inception V2 正在用 3x3 卷积层替换 Inception V1 的 5x5 卷积层,以提高性能。不过,我一直在学习使用 Tensorflow 对象检测 API 创建模型,该 API 可在此 link 中找到。

我一直在找API,定义faster r-cnn inception v2模块的代码在哪里,找到了。该架构在我在 /models/research/slim/nets 文件夹中找到的 inception_v2.py 文件中得到了很好的解释。这是步长为 2 的 3x3 卷积层的示例(如果我错了,请纠正我):

end_point = 'Conv2d_2c_3x3'
        net = slim.conv2d(net,depth(192),[3,3],scope=end_point)
        end_points[end_point] = net
        if end_point == final_endpoint:
          return net,end_points 

使用 Tensorflow 对象检测 API 时,每次我使用 export_inference_graph.py 将训练图导出到推理图时,所有卷积过程都显示在日志中。这就是我从日志本身得到的:

Profile:
node name | # parameters
_TFProfRoot (--/12.84m params)
  Conv (--/2.65m params)
    Conv/biases (512,512/512 params)
    Conv/weights (3x3x576x512,2.65m/2.65m params)
  FirstStageBoxPredictor (--/36.94k params)
    FirstStageBoxPredictor/BoxEncodingPredictor (--/24.62k params)
      FirstStageBoxPredictor/BoxEncodingPredictor/biases (48,48/48 params)
      FirstStageBoxPredictor/BoxEncodingPredictor/weights (1x1x512x48,24.58k/24.58k params)
    FirstStageBoxPredictor/Classpredictor (--/12.31k params)
      FirstStageBoxPredictor/Classpredictor/biases (24,24/24 params)
      FirstStageBoxPredictor/Classpredictor/weights (1x1x512x24,12.29k/12.29k params)
  FirstStageFeatureExtractor (--/4.25m params)
    FirstStageFeatureExtractor/InceptionV2 (--/4.25m params)
      FirstStageFeatureExtractor/InceptionV2/Conv2d_1a_7x7 (--/2.71k params)
        FirstStageFeatureExtractor/InceptionV2/Conv2d_1a_7x7/Batchnorm (--/0 params)
        FirstStageFeatureExtractor/InceptionV2/Conv2d_1a_7x7/depthwise_weights (7x7x3x8,1.18k/1.18k params)
        FirstStageFeatureExtractor/InceptionV2/Conv2d_1a_7x7/pointwise_weights (1x1x24x64,1.54k/1.54k params)
      FirstStageFeatureExtractor/InceptionV2/Conv2d_2b_1x1 (--/4.10k params)
        FirstStageFeatureExtractor/InceptionV2/Conv2d_2b_1x1/Batchnorm (--/0 params)
        FirstStageFeatureExtractor/InceptionV2/Conv2d_2b_1x1/weights (1x1x64x64,4.10k/4.10k params)
      FirstStageFeatureExtractor/InceptionV2/Conv2d_2c_3x3 (--/110.59k params)
        FirstStageFeatureExtractor/InceptionV2/Conv2d_2c_3x3/Batchnorm (--/0 params)
        FirstStageFeatureExtractor/InceptionV2/Conv2d_2c_3x3/weights (3x3x64x192,110.59k/110.59k params)
      FirstStageFeatureExtractor/InceptionV2/Mixed_3b (--/218.11k params)

然后我发现了这个:

FirstStageFeatureExtractor/InceptionV2/Conv2d_1a_7x7/Batchnorm (--/0 params)
FirstStageFeatureExtractor/InceptionV2/Conv2d_1a_7x7/depthwise_weights (7x7x3x8,1.18k/1.18k params)
FirstStageFeatureExtractor/InceptionV2/Conv2d_1a_7x7/pointwise_weights (1x1x24x64,1.54k/1.54k params)

在第一阶段的特征提取器中,为什么有一个 7x7 的卷积层?为什么使用它? inception_v2.py 中定义了 2 个 7x7 conv 层:

depthwise_multiplier = min(int(depth(64) / 3),8)
          net = slim.separable_conv2d(
              inputs,depth(64),[7,7],depth_multiplier=depthwise_multiplier,stride=2,padding='SAME',weights_initializer=trunc_normal(1.0),scope=end_point)

还有这个:

net = slim.conv2d(
              inputs,scope=end_point)

有可分离的转化。层和普通的 7x7 conv 层。我不明白它们是如何工作的。

而且,后来我找到了这段代码的解释:

 Args:
    inputs: a tensor of shape [batch_size,height,width,channels].
    final_endpoint: specifies the endpoint to construct the network up to. It
      can be one of ['Conv2d_1a_7x7','MaxPool_2a_3x3','Conv2d_2b_1x1','Conv2d_2c_3x3','MaxPool_3a_3x3','Mixed_3b','Mixed_3c','Mixed_4a','Mixed_4b','Mixed_4c','Mixed_4d','Mixed_4e','Mixed_5a','Mixed_5b','Mixed_5c']. If include_root_block is False,['Conv2d_1a_7x7','MaxPool_3a_3x3'] will
      not be available.
 use_separable_conv: Use a separable convolution for the first layer
      Conv2d_1a_7x7. If this is False,use a normal convolution instead.

如果 include_root_block 为 False,['Conv2d_1a_7x7'、'MaxPool_2a_3x3'、'Conv2d_2b_1x1'、'Conv2d_2c_3x3'、'MaxPool_3a_3x3'] 将不可用。

use_separable_conv:对第一层使用可分离卷积 Conv2d_1a_7x7。如果这是 False,请改用普通卷积

但是,include_root_block 是正确的。 args 定义在:

def inception_v2_base(inputs,final_endpoint='Mixed_5c',min_depth=16,depth_multiplier=1.0,use_separable_conv=True,data_format='NHWC',include_root_block=True,scope=None):

什么是 include_root_block ?什么是 use_separable_conv ?为什么它们的值是真的?不是 inception v2 没有 7x7 层吗? (如果我错了,抱歉)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?