zoukankan      html  css  js  c++  java
  • 134、TensorFlow检查点checkpoint文件中的信息

    # 1、你想创建多少Saver对象就可以创建多少,如果你需要去保存和恢复不同的子图模型
    # 同样的变量可以在不同的saver对象中被加载
    # 只有在Saver.restore()方法被调用的时候才会对变量的值进行计算
    # 2、如果你在session开始的时候只恢复一部分变量的值。
    # 你必须重新初始化其他变量的值
    # 3、如果想检查checkpoint文件中变量的值,可以使用print_tensors_in_checkpoint_file函数
    # 4、默认情况下,Saver使用tf.Variable.name属性来保存变量
    # 然而当你创建一个Saver对象的时候,你或许可以为checkpoint文件中的变量选择一个名字
    
    # 检查checkpoint文件中的变量
    import tensorflow as tf
    # import the inspect_checkpoint library
    from tensorflow.python.tools import inspect_checkpoint as chkp
    # print all tensors in checkpoint file
    chkp.print_tensors_in_checkpoint_file("tmp/model.ckpt", tensor_name=None, all_tensors=True, all_tensor_names=True)
    # print only tensor v1 in checkpoint file
    chkp.print_tensors_in_checkpoint_file("tmp/model.ckpt", tensor_name='v1', all_tensors=False, all_tensor_names=False)
    
    # print only tensor v2 in checkpoint file
    chkp.print_tensors_in_checkpoint_file("tmp/model.ckpt", tensor_name='v2', all_tensors=False, all_tensor_names=False)

    下面是输出的结果:

    tensor_name:  v1
    [ 1.  1.  1.]
    tensor_name:  v2
    [-1. -1. -1. -1. -1.]
    tensor_name:  v1
    [ 1.  1.  1.]
    tensor_name:  v2
    [-1. -1. -1. -1. -1.]
  • 相关阅读:
    noip模拟赛 钻石
    noip模拟赛 整除
    noip模拟赛 拼不出的数
    noip模拟赛 正方形
    noip模拟赛 财富
    noip模拟赛 a
    Java基础知识强化23:Java中数据类型转换(面试题)
    Java基础知识强化22:Java中数据类型转换
    Java基础知识强化21:Java中length、length()、size()区别
    MySQL(12):windows下解决mysql忘记密码
  • 原文地址:https://www.cnblogs.com/weizhen/p/8451514.html
Copyright © 2011-2022 走看看