未验证 提交 f233db02 编写于 作者: M mamingjie-China 提交者: GitHub

Merge pull request #35 from PaddlePaddle/develop

更新数据
......@@ -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
......
......@@ -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)
......
......@@ -762,6 +762,29 @@ class TFOpMapper(OpMapper):
output=node,
param_attr=attr)
def MirrorPad(self, node):
input = self.graph.get_node(node.layer.input[0], copy=True)
paddings = self.graph.get_node(node.layer.input[1], copy=True)
assert paddings.layer_type == "Const", "Padding should be Const"
self.add_omit_nodes(paddings.layer_name, node.layer_name)
paddings = paddings.value.flatten().tolist()
mode = node.get_attr("mode").decode()
assert mode == "REFLECT", "Only support 'REFLECT` mode in MirrorPad"
if input.tf_data_format == "NHWC" and len(input.out_shapes[0]) == 4:
paddings = [paddings[i] for i in [0, 1, 6, 7, 2, 3, 4, 5]]
pad_op = "pad"
if len(input.out_shapes[0]) == 4:
if paddings[0] + paddings[1] + paddings[2] + paddings[3] == 0:
paddings = paddings[4:]
pad_op = "pad2d"
attr = {"paddings": paddings, "mode": string("reflect")}
node.fluid_code.add_layer(pad_op,
inputs=input,
output=node,
param_attr=attr)
def Range(self, node):
start = self.graph.get_node(node.layer.input[0], copy=True)
limit = self.graph.get_node(node.layer.input[1], copy=True)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册