tensorflow初探-checkpoint转换成pb

reader = tf.train.NewCheckpointReader(ckpt_file)

with tf.Session() as sess:
    for key in reader.get_variable_to_shape_map():
       tf.Variable(reader.get_tensor(key), name=key)

    #tf.global_variables_initializer()

    with tf.gfile.FastGFile(pb_file, "wb") as f:
        f.write(sess.graph_def.SerializeToString())