Caffe 和 Keras 在应用 MAX 池时的区别

differences between Caffe and Keras when applying MAX pooling

我正在做一个将 keras json 模型转换为 caffe prototxt 的项目
caffe 支持任意填充值
keras(在tensorflow之上)支持'same'和'valid'值

对于caffe中的任何填充值,我们可以在keras中手动添加ZeroPadding层,然后应用'valid'方案来获得相同的输出尺寸

来自 https://github.com/MarcBS/keras/blob/master/keras/caffe/README.md

Given the differences between Caffe and Keras when applying the MAX pooling opperation, in some occasions the MAX pooling layers must include a pad: 1 value even if they did not include them in their original .prototxt

这两个框架在MAX pooling的实现上到底有什么区别?

池化实现的差异 - 在keras中,half-windows被丢弃。 Caffe 将额外输出 half-windows.
填充方案的差异 - keras 中的 'same' 填充有时会导致上下(或左右)的填充值不同。 caffe 始终在两侧均匀填充,因此上下(或左右)填充值始终相等。