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) #加载权重
    自己选择的路,跪着也要走完。朋友们,虽然这个世界日益浮躁起来,只要能够为了当时纯粹的梦想和感动坚持努力下去,不管其它人怎么样,我们也能够保持自己的本色走下去。
  • 相关阅读:
    RQNOJ 34 紧急援救
    Codevs 2080 特殊的质数肋骨
    POJ2975 Nim
    Bzoj1016 最小生成树计数
    POJ3613 Cow Relays
    POJ1386 Play on Words
    [从hzwer神犇那翻到的模拟赛题] 合唱队形
    HDU2824 The Euler function
    HDU1576 A/B
    HDU2669 Romantic
  • 原文地址:https://www.cnblogs.com/WTSRUVF/p/15049447.html
Copyright © 2011-2022 走看看