How to restore a model by filename in Tensorflow r12?

前端 未结 6 555
隐瞒了意图╮
隐瞒了意图╮ 2020-12-28 08:44

I have run the distributed mnist example: https://github.com/tensorflow/tensorflow/blob/r0.12/tensorflow/tools/dist_test/python/mnist_replica.py

Though I have set th

6条回答
  •  情深已故
    2020-12-28 09:18

    You can restore the model like this:

    saver = tf.train.import_meta_graph('./src/models/20170512-110547/model-20170512-110547.meta')
                saver.restore(sess,'./src/models/20170512-110547/model-20170512-110547.ckpt-250000'))
    

    Where the path '/src/models/20170512-110547/' contains three files:

    model-20170512-110547.meta
    model-20170512-110547.ckpt-250000.index
    model-20170512-110547.ckpt-250000.data-00000-of-00001
    

    And if in one directory there are more than one checkpoints,eg: there are checkpoint files in the path ./20170807-231648/:

    checkpoint     
    model-20170807-231648-0.data-00000-of-00001   
    model-20170807-231648-0.index    
    model-20170807-231648-0.meta   
    model-20170807-231648-100000.data-00000-of-00001   
    model-20170807-231648-100000.index   
    model-20170807-231648-100000.meta
    

    you can see that there are two checkpoints, so you can use this:

    saver =    tf.train.import_meta_graph('/home/tools/Tools/raoqiang/facenet/models/facenet/20170807-231648/model-20170807-231648-0.meta')
    
    saver.restore(sess,tf.train.latest_checkpoint('/home/tools/Tools/raoqiang/facenet/models/facenet/20170807-231648/'))
    

提交回复
热议问题