diff --git a/x2paddle/decoder/caffe_decoder.py b/x2paddle/decoder/caffe_decoder.py index 33b203cebb71eb16675e884b095d508596fcd57c..fee1abd017b6723548d133af0cb42a06f36bf965 100644 --- a/x2paddle/decoder/caffe_decoder.py +++ b/x2paddle/decoder/caffe_decoder.py @@ -246,9 +246,14 @@ 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)) + else: c_o = blob.num c_i = blob.channels diff --git a/x2paddle/op_mapper/caffe_custom_layer/normalize.py b/x2paddle/op_mapper/caffe_custom_layer/normalize.py index a63dc62cf9b9fc0dcd0badb5b189e66cbc7e0cd3..577a674f7e70aebee78735611c11e7202b2ccf7e 100644 --- a/x2paddle/op_mapper/caffe_custom_layer/normalize.py +++ b/x2paddle/op_mapper/caffe_custom_layer/normalize.py @@ -12,16 +12,14 @@ def normalize_layer(inputs, input_shape=None, name=None): assert across_spatial == False, "Only support across_spatial == False for Normalize" - input = inputs[0] 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]], + shape=[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)