i want to use this model on android platform, so transfer ckpt model to pb model, but just one op in the graph. and the pb model is null , just 70Byte size.
the transfer code is blow:
``import tensorflow as tf
from tensorflow.python.framework import graph_util
from tensorflow.python.platform import gfile
def freeze_graph(ckpt, output_graph):
output_node_names = "logits/biases"
saver = tf.train.import_meta_graph(ckpt+'.meta', clear_devices=False)
graph = tf.get_default_graph()
input_graph_def = graph.as_graph_def()
with tf.Session() as sess:
saver.restore(sess, ckpt)
output_graph_def = graph_util.convert_variables_to_constants(
sess=sess,
input_graph_def=input_graph_def,
output_node_names=output_node_names.split(',')
)
with tf.gfile.GFile(output_graph, 'wb') as fw:
fw.write(output_graph_def.SerializeToString())
print ('{} ops in the final graph.'.format(len(output_graph_def.node)))
ckpt = './04/model.ckpt'
pb = './04/model.pb'
if __name__ == '__main__':
freeze_graph(ckpt, pb)
the result is blow
Instructions for updating:
Use tf.compat.v1.graph_util.extract_sub_graph
1 ops in the final graph.
i want to use this model on android platform, so transfer ckpt model to pb model, but just one op in the graph. and the pb model is null , just 70Byte size.
the transfer code is blow:
the result is blow