Tensorflow额外输出节点

时间:2019-02-03 13:00:51

标签: python tensorflow machine-learning deep-learning artificial-intelligence

我在tf图中使用了以下功能

flipped_x = tf.image.flip_left_right(x)

但这会为图形添加一个额外的输出节点

flip_left_right/assert_positive/assert_less/All:0

为什么会这样?并有办法删除它吗?

我的tf图如下:

graph = tf.Graph()
with graph.as_default():
    with tf.Session() as sess:

        x = tf.placeholder(tf.uint8, name='uint_img')
        x = tf.to_float(x,name='input_images')
        x = tf.subtract(x, 127.5, name='submean')
        x = tf.multiply(x,0.0078125, name='normalized_images')

        flipped_x = tf.image.flip_left_right(x)
        combined_x = tf.concat([x,flipped_x],0,name="concat_input")

        pre_graph_def = graph.as_graph_def(add_shapes=True)
        pre_graph = tf.import_graph_def(pre_graph_def)

        dropout=tf.convert_to_tensor(1.0)

        saver = tf.train.import_meta_graph("model.ckpt.meta",input_map={'dropout_rate:0':dropout, 'img_inputs:0': combined_x})
        saver.restore(sess, ".ckpt")

        model_out = tf.get_default_graph().get_tensor_by_name("out:0")
        normal_embs, flipped_embs = tf.split(model_out, 2, name="split_flip_normal")
        combined_ = tf.add(normal_embs,flipped_embs, name = "combine_embs")
        out = tf.nn.l2_normalize(combined_, name="face_representation")

        frozen_graph = tf.graph_util.convert_variables_to_constants(
            sess,
            tf.get_default_graph().as_graph_def(),
            output_node_names=[out.op.name])

        with open('end_to_end_model.pb', 'wb') as f:
            f.write(frozen_graph.SerializeToString())

创建此图是为了向现有模型添加预处理和后期处理。

0 个答案:

没有答案