通过ckpt模型进行测试,以及通过ckpt对pb模型进行测试,结果是完全不同的。是什么原因?

时间:2019-01-10 03:28:54

标签: python-3.x tensorflow

该模型为resnet v1_50。调用模型时,输入节点为fifo_queue_Dequeue,输出节点为resnet_v1_50 / SpatialSqueeze

将ckpt转换为pb的代码如下:

slim = tf.contrib.slim

tf.logging.set_verbosity(tf.logging.INFO)
config = tf.ConfigProto(allow_soft_placement=True)
config.gpu_options.allow_growth = True
restore_saver = tf.train.import_meta_graph(r'E:\条烟 
\traindir\0108/model.ckpt-108460.meta',clear_devices=True)
with tf.Session(graph=tf.get_default_graph(),config = config) as sess:

    sess.run(tf.global_variables_initializer())

    restore_saver.restore(sess, r'E:\条烟\traindir\0108/model.ckpt- 
 108460')

    output_graph_def = tf.graph_util.convert_variables_to_constants(
        sess, sess.graph.as_graph_def(),output_node_names= 
 ["resnet_v1_50/SpatialSqueeze"])

    tf.train.write_graph(output_graph_def, '', r"D:\3.pb", as_text=False)
    tf.train.write_graph(output_graph_def, '', 
 r"D:\0108\ckpt_to_pb.pbtxt", as_text=True)

0 个答案:

没有答案