From 3718df765bbf52132329eda26e7d70c67e520e2d Mon Sep 17 00:00:00 2001 From: SunAhong1993 Date: Mon, 4 Nov 2019 16:51:11 +0800 Subject: [PATCH] fix the normalize --- x2paddle/decoder/caffe_decoder.py | 4 ++++ x2paddle/op_mapper/caffe_custom_layer/normalize.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/x2paddle/decoder/caffe_decoder.py b/x2paddle/decoder/caffe_decoder.py index 33b203c..f3fab9a 100644 --- a/x2paddle/decoder/caffe_decoder.py +++ b/x2paddle/decoder/caffe_decoder.py @@ -246,6 +246,10 @@ class CaffeDecoder(object): if layer.type == 'PReLU': c_o, c_i, h, w = map(int, [1] + \ list(dims) + [1]* (3 - len(dims))) + elif layer.type == 'Normalize': + data = np.asarray(list(blob.data), dtype=np.float32) + transformed.append(data) + continue else: c_o, c_i, h, w = map(int, [1] * (4 - len(dims)) \ + list(dims)) diff --git a/x2paddle/op_mapper/caffe_custom_layer/normalize.py b/x2paddle/op_mapper/caffe_custom_layer/normalize.py index a63dc62..3ec1ef9 100644 --- a/x2paddle/op_mapper/caffe_custom_layer/normalize.py +++ b/x2paddle/op_mapper/caffe_custom_layer/normalize.py @@ -17,11 +17,11 @@ def normalize_layer(inputs, l2_norm = fluid.layers.l2_normalize(input, axis=1, name=name + '_l2') scale_param = fluid.layers.create_parameter( shape=[1] - if channel_shared else [input_shape[0][0], 1, 1, input_shape[0][1]], + if channel_shared else [input_shape[0][1]], dtype=input.dtype, attr=name + '_scale') scale_param = fluid.layers.reshape(x=scale_param, \ - shape=[1] if channel_shared else [input_shape[0][0], 1, 1, input_shape[0][1]]) + shape=[1] if channel_shared else [input_shape[0][1]]) out = fluid.layers.elementwise_mul(x=l2_norm, y=scale_param, axis=-1 if channel_shared else 1) -- GitLab