Tencent / ncnn

ncnn is a high-performance neural network inference framework optimized for the mobile platform
Other
20.13k stars 4.14k forks source link

在mxnet下的channel方向上做mean、max操作,将mxnet转成ncnn后reduction参数转换问题 #1976

Closed Aruen24 closed 4 years ago

Aruen24 commented 4 years ago

1、mxnet下channel方向做mean、max:

mxnet版本1.5.0,symbol json { "op": "broadcast_mul", "name": "broadcast_mul0", "inputs": [[45, 0, 0], [55, 0, 0]] }, { "op": "mean", "name": "vargface_head_head_poolings_sa_mean", "attrs": { "axis": "1", "keepdims": "True" }, "inputs": [[56, 0, 0]] }, { "op": "max", "name": "vargface_head_head_poolings_sa_max", "attrs": { "axis": "1", "keepdims": "True" }, "inputs": [[56, 0, 0]] }, { "op": "Concat", "name": "vargface_head_head_poolings_sa_concat_body", "attrs": { "dim": "1", "num_args": "2" }, "inputs": [[57, 0, 0], [58, 0, 0]] }

mx转换成ncnn后:

`Reduction vargface_stage_4_unit_4s_sa_mean 1 1 broadcast_mul22_splitncnn_2 vargface_stage_4_unit_4s_sa_mean 0=3 1=1 4=1

Reduction vargface_stage_4_unit_4s_sa_max 1 1 broadcast_mul22_splitncnn_1 vargface_stage_4_unit_4s_sa_max 0=4 1=1 4=1

Concat vargface_stage_4_unit_4s_sa_concat_body 2 1 vargface_stage_4_unit_4s_sa_mean vargface_stage_4_unit_4s_sa_max vargface_stage_4_unit_4s_sa_concat_body 0=0`

在ncnn的reduction.cpp中

`int Reduction::load_param(const ParamDict& pd) { operation = pd.get(0, 0); reduce_all = pd.get(1, 1); coeff = pd.get(2, 1.f); axes = pd.get(3, Mat()); keepdims = pd.get(4, 0);

return 0;

}` 转换成ncnn后的参数0=3 1=1 4=1,使reduce_all = pd.get(1, 1); reduce_all=1会对w、h、c三个方向都做reduce,而不是对channel方向做reduce。

nihui commented 4 years ago

修了下,请测试

Aruen24 commented 4 years ago

修了下,请测试

用新的mxnet2ncnn转换后测试了一下,问题解决了!