层的尺寸不是整数时是向上取整还是向下取整?

Is the dimensions of layers rounded up or rounded down when it is not an integer?

有时可能会发生 conv 或 pool 层的过滤器掩码不适合输入量的情况。例如,我有一个 5x5 输入和一个 2x2 过滤器掩码,并且不使用任何填充,而 stride 的 d 值为 2..

使用公式:

H = 1 + (W - F + 2*P) / S 

其中 W 是输入量,F 是滤波器大小,P 是填充,S 是步幅 - 都是一维的。

1 + (5 - 2)/2 = 3/2 = 2,5 

使用的输出尺寸是多少?它会下降到“2”还是上升到“3”?

考虑到 caffe 的实施,它将降低到 2。 $CAFFE_ROOT/src/caffe/layers/conv_layer.cpp

第 18 行
 const int output_dim = (input_dim + 2 * pad_data[i] - kernel_extent)
        / stride_data[i] + 1;

基本上,考虑一个在输入上滑动的大小为 SxS 的过滤器。 当它移动到最后时,它可能不得不面对等于或小于其大小的输入。 如果它小于 S ,那么那部分是 ignored.This 是 caffe 实现它的方式。