caffe segnet 报错

Params 'pad_out_{}_' are deprecated. Please declare upsample height and width useing the upsample_h, upsample_w parameters.

查了一下,segnet的长宽需要设成32的倍数,要不然就要指定upsample_w upsample_h 大小;
参考链接:
https://blog.csdn.net/hong__fang/article/details/78421803?utm_source=blogxgwz8

message UpsampleParameter {
// DEPRECATED. No need to specify upsampling scale factors when
// exact output shape is given by upsample_h, upsample_w parameters.
optional uint32 scale = 1 [default = 2];
// DEPRECATED. No need to specify upsampling scale factors when
// exact output shape is given by upsample_h, upsample_w parameters.
optional uint32 scale_h = 2;
// DEPRECATED. No need to specify upsampling scale factors when
// exact output shape is given by upsample_h, upsample_w parameters.
optional uint32 scale_w = 3;
// DEPRECATED. Specify exact output height using upsample_h. This
// parameter only works when scale is 2
optional bool pad_out_h = 4 [default = false];
// DEPRECATED. Specify exact output width using upsample_w. This
// parameter only works when scale is 2
optional bool pad_out_w = 5 [default = false];
optional uint32 upsample_h = 6;
optional uint32 upsample_w = 7;
}
可设置参数为:
scale
scale_h scale_w
pad_out_h pad_out_w
upsample_h upsample_w

(1)先判断是否指定 upsample_hupsample_w,如果指定,大小为指定大小,否则(2)

(2)判断是否指定 scale_h, 如果未指定, scale_h_ = scale_w_ = scale,否则(3)

(3)scale_h_ = scale_h scale_w_=scale_w

只有scale_h_ = scale_w_ =2时,才可以指定pad_out_h,pad_out_w,否则错误,如果是(2)(3)则top特征图大小为:

   upsample_h_ = bottom[0]->height() *  scale_h_ - int(pad_out_h) 

   upsample_w_ = bottom[0]->width() *  scale_w_ - int(pad_out_w) 

注:

(1)如果输入图像的高和宽不是32的整数倍,需要指定upsample_h, upsample_w的大小,不然会出现维度不一致的错误,原因是upsample需要借助编码过程中pool层的位置信息,例如: pool前特征图大小为45, pool后为23,如果直接对23 unsample, 其大小为46, 而pool产生的位置图大小为45,造成upsample时大小不一致;

(2)指定upsample_h upsample_w的大小时,需要根据编码过程中对应pool特征图的大小,来设定upsample的大小,例如样例proto中输入图像大小为480*360, 以360分析:360—pool1(180)—pool2 (90)—pool3 (45)—pool4(23)—pool5(12), upsample5需要借助pool4位置信息,需要与pool4大小一致,因此upsamle_h=23 ~
layer {
name: "upsample4"
type: "Upsample"
bottom: "conv5_1_D"
top: "pool4_D"
bottom: "pool4_mask"
upsample_param {
scale: 2
upsample_w: 60
upsample_h: 45
}
}

我的解决办法:
在出错前面caffe会打印出top维度,一个个翻pool 的top,如下:
relu4_3 <- conv4_3
I1214 11:57:49.440979 20931 net.cpp:395] relu4_3 -> conv4_3 (in-place)
I1214 11:57:49.440987 20931 net.cpp:150] Setting up relu4_3
I1214 11:57:49.440994 20931 net.cpp:157] Top shape: 1 64 25 25 (40000)
I1214 11:57:49.440999 20931 net.cpp:165] Memory required for data: 119680000
I1214 11:57:49.441007 20931 layer_factory.hpp:77] Creating layer pool4
I1214 11:57:49.441026 20931 net.cpp:100] Creating Layer pool4
I1214 11:57:49.441032 20931 net.cpp:434] pool4 <- conv4_3
I1214 11:57:49.441041 20931 net.cpp:408] pool4 -> pool4
I1214 11:57:49.441049 20931 net.cpp:408] pool4 -> pool4_mask
I1214 11:57:49.441085 20931 net.cpp:150] Setting up pool4
I1214 11:57:49.441094 20931 net.cpp:157] Top shape: 1 64 13 13 (10816)
I1214 11:57:49.441102 20931 net.cpp:157] Top shape: 1 64 13 13 (10816)
I1214 11:57:49.441107 20931 net.cpp:165] Memory required for data: 119766528
I1214 11:57:49.441112 20931 layer_factory.hpp:77] Creating layer upsample4
I1214 11:57:49.441119 20931 net.cpp:100] Creating Layer upsample4
I1214 11:57:49.441126 20931 net.cpp:434] upsample4 <- pool4
I1214 11:57:49.441133 20931 net.cpp:434] upsample4 <- pool4_mask

Top shape: 1 64 13 13 (10816)
13 13 就是一个。
但是upsample4 对应上pool3 的top

posted @ 2019-12-14 13:41  无左无右  阅读(433)  评论(0编辑  收藏  举报