Tensorflow: How to convert .meta, .data and .index model files into one graph.pb file

前端 未结 4 1773

In tensorflow the training from the scratch produced following 6 files:

  1. events.out.tfevents.1503494436.06L7-BRM738
  2. model.ckpt-2248
4条回答
  •  抹茶落季
    2020-11-28 06:45

    First, use the following code to generate the graph.pb file. with tf.Session() as sess:

        # Restore the graph
        _ = tf.train.import_meta_graph(args.input)
    
        # save graph file
        g = sess.graph
        gdef = g.as_graph_def()
        tf.train.write_graph(gdef, ".", args.output, True)
    

    then, use summarize graph get the output node name. Finally, use

    python freeze_graph.py --input_graph=/path/to/graph.pbtxt --input_checkpoint=/path/to/model.ckpt-22480 --input_binary=false --output_graph=/path/to/frozen_graph.pb --output_node_names="the nodes that you want to output e.g. InceptionV3/Predictions/Reshape_1 for Inception V3 "
    

    to generate the freeze graph.

提交回复
热议问题