RPN网络(区域候选网络源码)

​​​​​RPN网络前面是一个提特征的网络,比如VGG,Res等,传给RPN网络的是一个特征图,RPN网络首先加了一个3*3*256*256的卷积层,之后在这个卷积之后,各自接了两个全连接层,一个输出18,一个输出36

输出特征图:13*13*256 

  1. #========= RPN ============  
  2. # 到我们的RPN网络部分了,前面的都是共享的5层卷积层的部分  
  3. layer {  
  4.   name: "rpn_conv1"  
  5.   type: "Convolution"  
  6.   bottom: "conv5"    #caffe中的数据是用blobs的形式进行数据流动的,每一层用bottom来输入数据,用top来输出数据。如果只有top没有bottom,则此层只有输出,没有输入。反之亦然。如果有多个 top或多个bottom,表示有多个blobs数据的输入和输出。
  7.   top: "rpn_conv1"  
  8.   param { lr_mult: 1.0 }  
  9.   param { lr_mult: 2.0 }  
  10.   convolution_param {  
  11.     num_output: 256  
  12.     kernel_size: 3 pad: 1 stride: 1 #这里作者把每个滑窗3*3,通过3*3*256*256的卷积核输出256维,完整的输出其实是12*12*256,  
  13.     weight_filler { type: "gaussian" std: 0.01 }  
  14.     bias_filler { type: "constant" value: 0 }  
  15.   }  
  16. }  
  17. layer {  
  18.   name: "rpn_relu1"  
  19.   type: "ReLU"  
  20.   bottom: "rpn_conv1"  
  21.   top: "rpn_conv1"  
  22. }  
  23. layer {  
  24.   name: "rpn_cls_score"  
  25.   type: "Convolution"  
  26.   bottom: "rpn_conv1"  
  27.   top: "rpn_cls_score"  
  28.   param { lr_mult: 1.0 }  
  29.   param { lr_mult: 2.0 }  
  30.   convolution_param {  
  31.     num_output: 18   # 2(bg/fg) * 9(anchors)  
  32.     kernel_size: 1 pad: 0 stride: 1 #这里看的很清楚,作者通过1*1*256*18的卷积核,将前面的256维数据转换成了18个输出  
  33.     weight_filler { type: "gaussian" std: 0.01 }  
  34.     bias_filler { type: "constant" value: 0 }  
  35.   }  
  36. }  
  37. layer {  
  38.   name: "rpn_bbox_pred"  
  39.   type: "Convolution"  
  40.   bottom: "rpn_conv1"  
  41.   top: "rpn_bbox_pred"  
  42.   param { lr_mult: 1.0 }  
  43.   param { lr_mult: 2.0 }  
  44.   convolution_param {  
  45.     num_output: 36   # 4 * 9(anchors)  
  46.     kernel_size: 1 pad: 0 stride: 1 <span style="font-family: Arial, Helvetica, sans-serif;">#这里看的很清楚,作者通过1*1*256*36的卷积核,将前面的256维数据转换成了36个输出</span>  
  47.     weight_filler { type: "gaussian" std: 0.01 }  
  48.     bias_filler { type: "constant" value: 0 }  
  49.   }  
  50. }  
  51. layer {  
  52.    bottom: "rpn_cls_score"  
  53.    top: "rpn_cls_score_reshape" # 我们之前说过,其实这一层是12*12*256的,所以后面我们要送给损失函数,需要将这个矩阵reshape一下,我们需要的是144个滑窗,每个对应的256的向量  
  54.    name: "rpn_cls_score_reshape"  
  55.    type: "Reshape"  ##改变数据的维度
  56.    reshape_param { shape { dim: 0 dim: 2 dim: -1 dim: 0 } }  
  57. }  
  58. layer {  
  59.   name: 'rpn-data'  
  60.   type: 'Python'  
  61.   bottom: 'rpn_cls_score'  
  62.   bottom: 'gt_boxes'  
  63.   bottom: 'im_info'  
  64.   bottom: 'data'  
  65.   top: 'rpn_labels'  
  66.   top: 'rpn_bbox_targets'  
  67.   top: 'rpn_bbox_inside_weights'  
  68.   top: 'rpn_bbox_outside_weights'  
  69.   python_param {  
  70.     module: 'rpn.anchor_target_layer'  
  71.     layer: 'AnchorTargetLayer'  ###产生anchor,并对anchor进行评分等操作。
  72.     param_str: "'feat_stride': 16"  
  73.   }  
  74. }  
  75. layer {  
  76.   name: "rpn_loss_cls"  
  77.   type: "SoftmaxWithLoss" # 很明显这里是计算softmax的损失,输入labels和cls layer的18个输出(中间reshape了一下),输出损失函数的具体值  
  78.   bottom: "rpn_cls_score_reshape"  
  79.   bottom: "rpn_labels"  
  80.   propagate_down: 1  
  81.   propagate_down: 0  
  82.   top: "rpn_cls_loss"  
  83.   loss_weight: 1  
  84.   loss_param {  
  85.     ignore_label: -1  
  86.     normalize: true  
  87.   }  
  88. }  
  89. layer {  
  90.   name: "rpn_loss_bbox"  
  91.   type: "SmoothL1Loss" # 这里计算的框回归损失函数具体的值  
  92.   bottom: "rpn_bbox_pred"  
  93.   bottom: "rpn_bbox_targets"  
  94.   bottom: "rpn_bbox_inside_weights"  
  95.   bottom: "rpn_bbox_outside_weights"  
  96.   top: "rpn_loss_bbox"  
  97.   loss_weight: 1  
  98.   smooth_l1_loss_param { sigma: 3.0 }  
  99. }  
  100.   
  101. #========= RCNN ============  
  102. # Dummy layers so that initial parameters are saved into the output net  
  103.   
  104. layer {  
  105.   name: "dummy_roi_pool_conv5"  
  106.   type: "DummyData"  
  107.   top: "dummy_roi_pool_conv5"  
  108.   dummy_data_param {  
  109.     shape { dim: 1 dim: 9216 }  
  110.     data_filler { type: "gaussian" std: 0.01 }  
  111.   }  
  112. }  
  113. layer {  
  114.   name: "fc6"  
  115.   type: "InnerProduct"  
  116.   bottom: "dummy_roi_pool_conv5"  
  117.   top: "fc6"  
  118.   param { lr_mult: 0 decay_mult: 0 }  
  119.   param { lr_mult: 0 decay_mult: 0 }  
  120.   inner_product_param {  
  121.     num_output: 4096  
  122.   }  
  123. }  
  124. layer {  
  125.   name: "relu6"  
  126.   type: "ReLU"  
  127.   bottom: "fc6"  
  128.   top: "fc6"  
  129. }  
  130. layer {  
  131.   name: "fc7"  
  132.   type: "InnerProduct"  
  133.   bottom: "fc6"  
  134.   top: "fc7"  
  135.   param { lr_mult: 0 decay_mult: 0 }  
  136.   param { lr_mult: 0 decay_mult: 0 }  
  137.   inner_product_param {  
  138.     num_output: 4096  
  139.   }  
  140. }  
  141. layer {  
  142.   name: "silence_fc7"  
  143.   type: "Silence"  
  144.   bottom: "fc7"  
  145. }  
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值