tensorflow学习之——从保存的权重中使用tensorboard查看网络

0. 写作目的

好记性不如烂笔头。

1. tensorboard模型保存说明

采用tf.train.Saver保存的模型,主要文件有:

1) checkpoint : 用于记录训练过程中保存的各模型,在第一行会保存最新的模型的路径: model.ckpt

2)  model.ckpt.meta: 为保存的Graph,即网络

3) model.ckpt.index : 为string-string table,table的key值为tensor名,value为BundleEntryProto.

4) model.ckpt.data-00000-of-00001: 为Graph中的权重

2. tensorboard可视化网络

1.1 应用场景

对于别人训练好的tensorboard模型,包含的文件如1中所示。

然后加载图,并查看网络的结构。

modelDir = currentDir + '/model'
summariesDir =  currentDir + '/tensorboard'
def test_main():
    with tf.Session() as sess:
        model_file = tf.train.latest_checkpoint(modelDir)
        print(model_file)
        saver = tf.train.import_meta_graph(model_file + '.meta')  ## load the Graph without weights
        ## no need to load weights
        #saver.restore(sess,
        #              tf.train.latest_checkpoint(modelDir))

        if tf.gfile.Exists(summariesDir):
            tf.gfile.DeleteRecursively(summariesDir)
        if not os.path.exists( summariesDir):
            os.makedirs( summariesDir)

        merged = tf.summary.merge_all()
        train_writer = tf.summary.FileWriter(summariesDir + '/trainAugNewNet', tf.get_default_graph())
        test_writer = tf.summary.FileWriter(summariesDir + '/testAugNewNet')

 

运行结构大致如下:

tensorflow学习之——从保存的权重中使用tensorboard查看网络_第1张图片

你可能感兴趣的:(tensorflow学习,TensorFlow,tensorboard,从训练好的权重中得到网络视图)