how fcn can accept images with different sizes?

29 views
Skip to first unread message

Yang Li

unread,
Mar 31, 2017, 9:56:38 PM3/31/17
to Caffe Users
Hi all, now I'm confused. fcn can accept any size images. how it works? for example:
after conv1_1 with stride =1, kernel = 3, pad = 100, the input size is W, then W11 = (W - 3 + 2*100)/1 + 1 = W+198;
after conv1_2 with stride = 1, kernel = 3, pad = 1, then output size W12 = (W11 - 3 + 2*1) /1 +1 = W +198
after pool1 with stride = 2,  kernel = 2, then output size W13 = (W12 -2)/2+1 = W/2 + 99;
after conv2_1  with stride = 1, kernel = 3, pad = 1, then outputsize W21 = (W13 - 3 + 2*1)/1 +1 = W/2 + 99
after conv2_2 with stride = 1, kernel = 3, pad = 1, then outputsize W22 = (W21 - 3 +2*1)/1+1 = W/2 + 99
after pool2 with stride = 2,  kernel = 2, then output size W23 = (W22 -2)/2+1 = (W+198)/4.
and then, the problem is when (W + 198) cannot be divided by 4, the pool2 layer would be error, is there anybody could explain this for me? thank you very much!

Przemek D

unread,
Apr 3, 2017, 3:02:42 AM4/3/17
to Caffe Users
When a blob dimension cannot be divided (without remainder), the pool layer automatically pads it with zeros. So a blob of shape (1,1,3,3) and that of shape (1,1,4,4) will both be pooled (assuming kernel 2 and stride 2) into a (1,1,2,2) blob. There will be no error.
Additionally, in order to maintain the same dimensions of input data and the upscaled segmentation map, a Crop layer is used.
Reply all
Reply to author
Forward
0 new messages