From 4af3caecd8c2cf851a0b94a6be8679b4156050fe Mon Sep 17 00:00:00 2001 From: mamingjie-China Date: Sat, 8 Aug 2020 17:07:41 +0800 Subject: [PATCH] fix bug in paddle1.8.3 --- x2paddle/op_mapper/tf_op_mapper_nhwc.py | 7 +++---- x2paddle/optimizer/tf_optimizer.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/x2paddle/op_mapper/tf_op_mapper_nhwc.py b/x2paddle/op_mapper/tf_op_mapper_nhwc.py index 12c91f8..a5198cc 100644 --- a/x2paddle/op_mapper/tf_op_mapper_nhwc.py +++ b/x2paddle/op_mapper/tf_op_mapper_nhwc.py @@ -333,16 +333,15 @@ class TFOpMapperNHWC(OpMapper): "dilation": dilations[2:4], "padding": string(pad_mode) } - if hasattr(node, 'dilation') and attr['dilation'] == [1, 1]: if len(node.dilation) == 1: attr['dilation'] = [1, node.dilation[0]] - + if c == -1: reshape_attr = {"shape": [0, k_size[2], 0, 0]} node.fluid_code.add_layer( "reshape", inputs=input, output=input, param_attr=reshape_attr) - + node.fluid_code.add_layer( "conv2d", inputs=input, output=node, param_attr=attr) if not channel_first: @@ -759,6 +758,7 @@ class TFOpMapperNHWC(OpMapper): begin = begin.value.tolist() else: begin = self.decoder.infer_tensor(begin).tolist() + # shape = begin.out_shapes[0] # attr = {"shape": shape} # node.fluid_code.add_layer( @@ -1101,4 +1101,3 @@ class TFOpMapperNHWC(OpMapper): output = "{}[{}]".format(node.layer_name, i) node.fluid_code.add_layer( "data", inputs=None, output=output, param_attr=attr) - diff --git a/x2paddle/optimizer/tf_optimizer.py b/x2paddle/optimizer/tf_optimizer.py index a5bf84b..daeda64 100644 --- a/x2paddle/optimizer/tf_optimizer.py +++ b/x2paddle/optimizer/tf_optimizer.py @@ -863,7 +863,7 @@ class TFOptimizer(object): weight = numpy.expand_dims(weight, 2) weight = numpy.expand_dims(weight, 3) self.op_mapper.weights[in_nodes3[0].layer_name] = weight - # fix bug in Paddle1.8.3 and may change in next version + # fix bug in Paddle1.8.3 and may change in next version. self.op_mapper.weights[in_nodes3[0].layer_name + '_1'] = weight.reshape(1, -1) in_nodes3[0].fluid_code.layers[0].param_attr["shape"] = [ -- GitLab