diff --git a/x2paddle/decoder/tf_decoder.py b/x2paddle/decoder/tf_decoder.py index e645ac1d2e57142f14eca649f02e86debe04ab67..6e1486ffc30230c055fa2cd428bd2eb6eb8a9e7b 100644 --- a/x2paddle/decoder/tf_decoder.py +++ b/x2paddle/decoder/tf_decoder.py @@ -488,96 +488,4 @@ class TFDecoder(object): return results[0].tolist() else: raise Exception("Couldn't infer a stable shape shape tensor value") - -# def infer_tensor(self, graph_node): -# if hasattr(graph_node, "index"): -# tensor_name = graph_node.layer.name + ":{}".format(graph_node.index) -# else: -# tensor_name = graph_node.layer.name + ":0" -# feed = dict() -# for input_name, info in self.inputs_info.items(): -# (shape, dtype) = cp.deepcopy(info) -# input_tensor = self.sess.graph.get_tensor_by_name(input_name + ":0") -# if shape.count(-1) > 0: -# shape[shape.index(-1)] = 2 -# feed[input_tensor] = numpy.random.random_sample(shape) -# output_tensor = self.sess.graph.get_tensor_by_name(tensor_name) -# return self.sess.run([output_tensor], feed)[0] - -# def infer_shape_tensor(self, graph_node, out_shape=None): -# if hasattr(graph_node, "index"): -# tensor_name = graph_node.layer.name + ":{}".format(graph_node.index) -# else: -# tensor_name = graph_node.layer.name + ":0" -# feed = dict() -# batch_size = [2, 3, 5] -# results = list() -# for b in batch_size: -# for input_name, info in self.inputs_info.items(): -# (shape, dtype) = cp.deepcopy(info) -# input_tensor = self.sess.graph.get_tensor_by_name(input_name + -# ":0") -# if shape.count(-1) > 0: -# shape[shape.index(-1)] = b -# feed[input_tensor] = numpy.random.random_sample(shape) -# output_tensor = self.sess.graph.get_tensor_by_name(tensor_name) -# results.append(self.sess.run([output_tensor], feed)[0].flatten()) - -# compare01 = (results[0] == results[1]) -# compare12 = (results[1] == results[2]) - -# if compare01.all() and compare12.all(): -# return results[0].tolist() - -# if (compare01 == compare12).all(): -# index = numpy.argwhere(compare01 == False).flatten() -# if index.shape[0] != 1: -# raise Exception("There's not only one unstable dimension") -# results[0][index[0]] = -1 - -# index = numpy.argwhere(results[0] < 0).flatten() -# if index.shape[0] > 2: -# print("Warning: More than two dimension less than zero") -# if index.shape[0] == 2 and out_shape is not None: -# if out_shape[index[1]] > 0: -# results[0][index[1]] = out_shape[index[1]] -# else: -# results[0][index[0]] = out_shape[index[0]] -# return results[0].tolist() -# else: -# raise Exception("Couldn't infer a stable shape shape tensor value") - -# def infer_tensor_shape(self, graph_node): -# if hasattr(graph_node, "index"): -# tensor_name = graph_node.layer.name + ":{}".format(graph_node.index) -# else: -# tensor_name = graph_node.layer.name + ":0" -# feed = dict() -# batch_size = [2, 3, 5] -# shapes = list() -# for b in batch_size: -# for input_name, info in self.inputs_info.items(): -# (shape, dtype) = cp.deepcopy(info) -# input_tensor = self.sess.graph.get_tensor_by_name(input_name + -# ":0") -# if shape.count(-1) > 0: -# shape[shape.index(-1)] = b -# feed[input_tensor] = numpy.random.random_sample(shape) -# output_tensor = self.sess.graph.get_tensor_by_name(tensor_name) -# shape = self.sess.run([output_tensor], feed)[0].shape -# shapes.append(numpy.array(shape)) - -# compare01 = (shapes[0] == shapes[1]) -# compare12 = (shapes[1] == shapes[2]) - -# if compare01.all() and compare12.all(): -# return shape[0].tolist() - -# if (compare01 == compare12).all(): -# index = numpy.argwhere(compare01 == False).flatten() -# if index.shape[0] != 1: -# raise Exception("There's not only one unstable dimension") -# if index[0] != 0: -# raise Exception("Batch size not in the first dimension") -# shapes[0][0] = -1 -# return shapes[0].tolist() + \ No newline at end of file