diff --git a/x2paddle/decoder/tf_decoder.py b/x2paddle/decoder/tf_decoder.py index 25f11a99c1c446d3c668e53eed5e7b10683cc66f..06c30529b3a8a68691301324bd143c2e3db0e80d 100644 --- a/x2paddle/decoder/tf_decoder.py +++ b/x2paddle/decoder/tf_decoder.py @@ -312,7 +312,11 @@ class TFDecoder(object): right_shape_been_input = False while not right_shape_been_input: - shape = input("Shape of Input(e.g. None,224,224,3): ") + try: + shape = raw_input( + "Shape of Input(e.g. None,224,224,3): ") + except: + shape = input("Shape of Input(e.g. None,224,224,3): ") if shape.count("None") > 1: print("Only 1 dimension can be None, type again:)") else: diff --git a/x2paddle/op_mapper/tf_op_mapper.py b/x2paddle/op_mapper/tf_op_mapper.py index 2a7a6082997a442e00aa6f876ceef3536817be80..4eb68166e964e4c5b944012486cc68857c631f22 100644 --- a/x2paddle/op_mapper/tf_op_mapper.py +++ b/x2paddle/op_mapper/tf_op_mapper.py @@ -1010,7 +1010,7 @@ class TFOpMapper(OpMapper): attr = { "bias_attr": False, "param_attr": string(kernel.layer_name), - "num_filters": k_size[3], + "num_filters": k_size[2], "filter_size": k_size[0:2], "stride": strides[2:4], "dilation": dilations[2:4], diff --git a/x2paddle/op_mapper/tf_op_mapper_nhwc.py b/x2paddle/op_mapper/tf_op_mapper_nhwc.py index bf1786996ec86818b8a7205ebc17d825fb875651..06fec6923cca4ffdfee4b04070ba2c7f1bcd9906 100644 --- a/x2paddle/op_mapper/tf_op_mapper_nhwc.py +++ b/x2paddle/op_mapper/tf_op_mapper_nhwc.py @@ -1007,7 +1007,7 @@ class TFOpMapperNHWC(OpMapper): attr = { "bias_attr": False, "param_attr": string(kernel.layer_name), - "num_filters": k_size[3], + "num_filters": k_size[2], "filter_size": k_size[0:2], "stride": strides[2:4], "dilation": dilations[2:4], diff --git a/x2paddle/optimizer/tf_optimizer.py b/x2paddle/optimizer/tf_optimizer.py index 08f7b08a671301a319a2536200f120009102a59d..6431e439ccf463a1aa2c08ba1b1eac3f34d41175 100644 --- a/x2paddle/optimizer/tf_optimizer.py +++ b/x2paddle/optimizer/tf_optimizer.py @@ -517,7 +517,7 @@ class TFOptimizer(object): l.op = 'transpose' l.inputs = true_node.fluid_code.layers[3].output l.param_attr = {'perm': [0, 3, 1, 2]} - if type(l.inputs) == str: + if isinstance(l.inputs, six.string_types): l.output = l.inputs else: l.output = l.inputs.layer_name @@ -550,7 +550,7 @@ class TFOptimizer(object): node = self.graph.get_node(name) if len(node.out_shapes[0]) == 4 and node.tf_data_format == "NHWC": shape = node.fluid_code.layers[0].param_attr["shape"] - shape = [shape[i] for i in [0, 3, 1, 2]] + shape = [shape[j] for j in [0, 3, 1, 2]] node.fluid_code.layers[0].param_attr["shape"] = shape node.fluid_code.layers[0].output = "nhwc_" + name attr = {"perm": [0, 2, 3, 1]}