1. TensorFlow  生成的  .ckpt 和  .pb 都有什么用?

 

The .ckpt is the model given by tensorflow which includes all the 
weights/parameters in the model. The .pb file stores the computational
graph. To make tensorflow work we need both the graph and the
parameters. There are two ways to get the graph:
(1) use the python program that builds it in the first place (tensorflowNetworkFunctions.py).
(2) Use a .pb file (which would have to be generated by tensorflowNetworkFunctions.py).

.ckpt file is were all the intelligence is.


 

2. TensorFlow saving into/loading a graph from a file

       

       正好看到 StackOverflow 上有位仁兄问过相关的问题,整理的不错

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------





        From what I've gathered so far, there are several different ways of dumping a TensorFlow graph
into a file and then loading it into another program, but I haven't been able to find clear examples/information on how they work. What I already know is this:

  1. Save the model's variables into a checkpoint file (.ckpt) using a ​​tf.train.Saver()​​ and restore them later (​​source​​)
  2. Save a model into a .pb file and load it back in using ​​tf.import_graph_def()​​ (​​source​​)
  3. Load in a model from a .pb file, retrain it, and dump it into a new .pb file using Bazel (​​source​​)
  4. Freeze the graph to save the graph and weights together (​​source​​)
  5. Use ​​as_graph_def()​​ to save the model, and for weights/variables, map them into constants (​​source​​)

            However, I haven't been able to clear up several questions regarding these different methods:

            1. Regarding checkpoint files, do they only save the trained weights of a model? Could checkpoint files be loaded into a new program, and be used to run the model, or do they simply serve as ways to save the weights in a model at a certain time/stage?
            2. Regarding ​​Regarding Bazel, can it only save into/load from .pb files for retraining? Is there a simple Bazel command just to dump a graph into a .pb?​
            3. ​Regarding freezing, can a frozen graph be loaded in using The Android demo for TensorFlow loads in Google's Inception model from a .pb file. If I wanted to substitute my own .pb file, how would I go about doing that? Would I need to change any native code/methods?​
            4. ​In general, what exactly is the difference between all these methods? Or more broadly, what is the difference between ​​In short, what I'm looking for is a method to save both a graph (as in, the various operations and such) and its weights/variables into a file, which can then be used to load the graph and weights into another program, for use (not necessarily continuing/retraining).​​ 
              Documentation about this topic isn't very straightforward, so any answers/information would be greatly appreciated.


                     





                    1 Answer



                    ​active​​​​oldest​​​​votes​


                     



                    作者:柒月