zoukankan      html  css  js  c++  java
  • saver 的保存与恢复

    模型保存,先要创建一个Saver对象:saver=tf.train.Saver(),

    max_to_keep 是用来设置保存模型的个数,默认为5,即保存最近的五个模型,saver=tf.train.Saver(max_to_keep=0)

    如果你只想保存最后一代的模型,则只需要将max_to_keep设置为1:saver=tf.train.Saver(max_to_keep=1)

    创建完saver对象后,就可以保存训练好的模型了:saver.save(sess,'ckpt/mnist.ckpt',global_step=step)

    模型的恢复用的是restore()函数,它需要两个参数restore(sess, save_path),save_path指的是保存的模型路径。

    model_file=tf.train.latest_checkpoint('ckpt/') 自动获取最后一次保存的模型 

    saver.restore(sess,model_file)

    原博客:https://www.cnblogs.com/denny402/p/6940134.html

  • 相关阅读:
    设计模式六大原则
    .net Stream篇(七)
    .net Stream篇(六)
    .net Stream篇(五)
    .net Stream篇(四)
    Leetcode 18
    Leetcode 16
    Leetcode 15
    Leetcode 12
    Leetcode 9
  • 原文地址:https://www.cnblogs.com/smartwhite/p/8989174.html
Copyright © 2011-2022 走看看