tensorboard的使用

1、keras 与 tensorboard

from tensorflow.keras.callbacks import TensorBoard
filepath="snapshot/v2_weights-improvement-{epoch:02d}-{val_acc:.2f}.hdf5" tensorboard = TensorBoard(log_dir='logs/{}'.format(filepath)) callbacks_list = [checkpoint, tensorboard] model.fit(train_imgs, train_labels, validation_data=(test_imgs, test_labels) , batch_size=256, callbacks=callbacks_list, epochs=15, shuffle=True, verbose=0)

 终端  tensorboard --logdir="./log"

   http://localhost:6006(如果访问的是服务器,别忘记修改ip)

   https://stackoverflow.com/questions/42112260/how-do-i-use-the-tensorboard-callback-of-keras

 

2、模型可视化

     pb模型可视化 

v1 = tf.Variable(tf.constant(1, shape=[1]), name='v1')
v2 = tf.Variable(tf.constant(1, shape=[1]), name='v2')
result = v1 + v2


with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    graph = tf.get_default_graph()
    graph_def = graph.as_graph_def()
    output_grapg_def = tf.graph_util.convert_variables_to_constants(sess, graph_def, ["add"])

    with tf.gfile.GFile("Model/freeze_model.pb", 'wb') as f:
        f.write(output_grapg_def.SerializeToString())

    graph_def.ParseFromString(tf.gfile.GFile("Model/freeze_model.pb", 'rb').read())
    tf.import_graph_def(graph_def, name='graph')
    summary_writer = tf.summary.FileWriter('log/', graph)

 

 

 

    meta可视化

    

v1 = tf.Variable(tf.constant(1, shape=[1]), name='v1')
v2 = tf.Variable(tf.constant(1, shape=[1]), name='v2')
result = v1 + v2

saver = tf.train.Saver()
with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    print(sess.run(result))
    saver.save(sess, "Model/model.ckpt")

    graph = tf.get_default_graph()
    graph_def = graph.as_graph_def()
    _ = tf.train.import_meta_graph("Model/model.ckpt.meta")
    summary_writer = tf.summary.FileWriter("log/", graph)

 

转载于:https://www.cnblogs.com/573177885qq/p/10819102.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值