码迷,mamicode.com
首页 > 其他好文 > 详细

caffe,Inception v2 Check failed: top_shape[j] == bottom[i]->shape(j)

时间:2017-09-09 11:50:19      阅读:321      评论:0      收藏:0      [点我收藏+]

标签:tty   attr   方案   txt   pad   int   attribute   check   top   

使用Caffe 跑 Google 的Inception V2 对输入图片的shape有要求,某些shape输进去可能会报错。 
Inception model中有从conv和pooling层concat的操作,而conv和pooling的output输出计算方式不完全一样。解决方案: 
1. 按照原来prototxt输出图片 
2. 把concat层前面stride为2的conv层替换stride为1,再额外加上一个stride为2的pooling层 
e.g. 以 Inception v2 为例子InceptionBN 
conv_3c_3x3, conv_3c_double_3x3_1 
conv_4e_3x3, conv_4e_double_3x3_1 
然后再接上 stride 为2 的max pooling 层,这样几个分支出来的shape都会保持一致。

layer {
  name: "conv_3c_3x3"
  type: "Convolution"
  bottom: "conv_3c_3x3_reduce"
  top: "conv_3c_3x3"
  convolution_param { 
     num_output: 240
     kernel_size: 3
     stride: 1
     pad: 1
  }
}

layer {
  name: "max_pool_3c_3x3"
  type: "Pooling"
  bottom: "conv_3c_3x3"
  top: "conv_3c_3x3"
  pooling_param {
     pool: MAX
     kernel_size: 3
     stride: 2
     pad: 0
  }
}

这是取巧的做法,虽然保持了加载模型参数一致,但是增加了conv操作(stride变小)和多了一层pooling操作,会增加计算量和消耗显存。

caffe,Inception v2 Check failed: top_shape[j] == bottom[i]->shape(j)

标签:tty   attr   方案   txt   pad   int   attribute   check   top   

原文地址:http://www.cnblogs.com/guohaoyu110/p/7497341.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!