zoukankan      html  css  js  c++  java
  • 模型权重记录与恢复

    import tensorflow
    
    logdir = './logs'
    checkpoint_path = './checkpoint/Titanic.{epoch:02d}-{val_loss:.2f}.ckpt' #路径为当前目录下的checkpoint子目录,后边为命名规则
    callbacks = [tf.keras.callbacks.TensorBoard(log_dir = logdir, histogram_freq = 2), #参数一:日志文件目录, 参数二:直方图频率为2
                 tf.keras.callbacks.ModelCheckpoint(filepath = checkpoint_path, save_weights_only = True, verbose = 1, period = 5)]
                                                    #参数一:ckpt文件的路径,参数二:仅保存模型的权重,参数三:保存时的输出信息,参数四:周期
    logdir = './logs'
    checkpoint_path = './checkpoint/Titanic.{epoch:02d}-{val_loss:.2f}.ckpt'
    checkpoint_dir = os.path.dirname(checkpoint_path) #去掉文件名,返回目录
    latest = tf.train.latest_checkpoint(checkpoint_dir) #找到最新的checkpoint
    model.load_weights(latest) #加载权重
    自己选择的路,跪着也要走完。朋友们,虽然这个世界日益浮躁起来,只要能够为了当时纯粹的梦想和感动坚持努力下去,不管其它人怎么样,我们也能够保持自己的本色走下去。
  • 相关阅读:
    Unity接入九游SDK学习与踩坑
    Linux系统下实现Tomcat的安装和项目的部署:
    mac查看端口占用情况并结束进程
    BootStrap
    ES6
    JQuery
    CSS 、JavaScript
    HTML
    XML
    数据库连接池&DBUtils
  • 原文地址:https://www.cnblogs.com/WTSRUVF/p/15049447.html
Copyright © 2011-2022 走看看