0

I encountered a problem when try to convert the MXNet model to Caffe model. I find a nodes operation in MXNet that defined as "op"="mean", which seems not been perfectly supported in Caffe.

MXNet Node:

{
  "op": "mean", 
  "name": "mean0", 
  "attr": {
    "axis": "(2, 3)", 
    "keepdims": "True"
  }, 
  "inputs": [[781, 0, 0]]
}, 

According to https://mxnet.incubator.apache.org/api/python/symbol/symbol.html?highlight=mean#mxnet.symbol.mean

This node calculates the mean value separately on the axes2 and axes[3], and retain the same dimension size of input.

I find a layer in Caffe named "Reduction Layer" as http://caffe.berkeleyvision.org/tutorial/layers/reduction.html which seems doesn't support the mean operation.

Since my target is pretty simple, calculate the mean value on axe2 and [3] and return a full dimension sized tensor, I'm not sure whether there is a way to realize this based on the existing Caffe layers.

For example, I considered to use Convolution Layer in Caffe by setting kernel size=1, output=1, weight=1 to realize the average calculation, but how to define the calculation only happened on specific axes?

Any idea is welcome.

Thanks, Colin

1 Answers1

0

Reduction layer cannot be used for this purpose because reduction layer does not support averaging across multiple axis.

If you need this, you need to write your own layer. Here is good documentation to get started: https://github.com/BVLC/caffe/wiki/Simple-Example:-Sin-Layer

Indhu Bharathi
  • 1,437
  • 1
  • 13
  • 22
  • Hi Indhu, Thanks! I actually prepared to do so. I also found it's very interesting that caffe and tensorflow has little difference in the same nodes/layer, which could lead to totally different result, for instance, BatchNorm and Average pooling. So I kept modifying the source code of Caffe to accordingly same with tensorflow. Anyway, thanks again. – oscarriddle Mar 15 '18 at 10:01