Reputation: 1
I have a Caffe CNN model, and I am trying to import it to MATLAB using importCaffeNetwork
command, which gets prototxt and caffemodel files as input arguments.
However, I get this error:
The pooling layer 'pool1' is not compatible with MATLAB. Caffe computes the output size as [16 16 32] but MATLAB computes it as [15 15 32]
It seems that the error is related to the difference in output size calculation of pooling layer in MATLAB and CAFFE, where the former uses ceil
and the latter uses floor
function.
Is it the real source of problem? What can I do to solve this?
Upvotes: 0
Views: 1458
Reputation: 28449
This is because in caffe, the output size calculation for convolution layers and pooling layers are slightly different. Suppose input dim is h
, padding is p
, kernel size is k
and stride is s
, for convolutional layers, the output size is
floor((h+2*p-k)/s)+1
,
but for pooling layers, the output size is ceil((h+2*p-k)/s)+1
.
So the output size is different even if the parameters and input size are the same.
Adjust the parameter such as padding and stride and kernel size to ensure that the output is the same.
Upvotes: 4