TensorFlow保存TensorBoard圖像操作
簡(jiǎn)單的代碼:
import tensorflow as tf
In [2]: matrix1=tf.constant([[3.,3.]])
In [3]: matrix2=tf.constant([[2.],[2.]])
with tf.Session() as sess:
...: writer = tf.summary.FileWriter('./graph', sess.graph)
...: result = sess.run(tf.matmul(matrix1, matrix2))
...: writer.close()
ipython中使用!+命令可以直接運(yùn)行terminal命令。
terminal輸入: tensorboard --logdir graph/
跳出:Starting TensorBoard 54 at http://amax:6006
在瀏覽器輸入地址加端口號(hào)并在graph中查看。
補(bǔ)充知識(shí):tensorflow 利用保存的meta圖文件生成log供tensorboard可視化 保存恢復(fù)模型
tensorboard可視化圖:
import tensorflow as tf
g = tf.Graph()
with g.as_default() as g:
tf.train.import_meta_graph('criteo_80.meta')
with tf.Session(graph=g) as sess:
file_writer = tf.summary.FileWriter(logdir='./', graph=g)
保存恢復(fù)模型:
# 建模型 saver = tf.train.Saver() with tf.Session() as sess: # 存模型,注意此處的model是文件名非路徑 saver.save(sess, "/tmp/model") with tf.Session() as sess: # 恢復(fù)模型 saver.restore(sess, "/tmp/model")
# 先恢復(fù)圖
saver = tf.train.import_meta_graph("/tmp/model.meta")
with tf.Session() as sess:
# 再恢復(fù)參數(shù)
saver.restore(sess, "/tmp/model")
以上這篇TensorFlow保存TensorBoard圖像操作就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
OpenCV實(shí)戰(zhàn)記錄之基于分水嶺算法的圖像分割
在機(jī)器視覺(jué)中,有時(shí)需要對(duì)產(chǎn)品進(jìn)行檢測(cè)和計(jì)數(shù),其難點(diǎn)無(wú)非是對(duì)于產(chǎn)品的圖像分割,這篇文章主要給大家介紹了關(guān)于OpenCV實(shí)戰(zhàn)記錄之基于分水嶺算法的圖像分割的相關(guān)資料,需要的朋友可以參考下2023-02-02
Python人臉識(shí)別第三方庫(kù)face_recognition接口說(shuō)明文檔
Python人臉識(shí)別第三方庫(kù)face_recognition接口簡(jiǎn)單說(shuō)明,及簡(jiǎn)單使用方法2019-05-05
python opencv攝像頭的簡(jiǎn)單應(yīng)用
這篇文章主要為大家詳細(xì)介紹了python opencv攝像頭的簡(jiǎn)單應(yīng)用,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-06-06
Python 實(shí)現(xiàn)使用空值進(jìn)行賦值 None
這篇文章主要介紹了Python 實(shí)現(xiàn)使用空值進(jìn)行賦值 None,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-03-03
OpenCV每日函數(shù)之BarcodeDetector類(lèi)條碼檢測(cè)器
OpenCV在V4.5.3版本的contrib包中提供了一個(gè)barcode::BarcodeDetector類(lèi),用于條形碼的識(shí)別,這篇文章主要介紹了OpenCV每日函數(shù)?BarcodeDetector條碼檢測(cè)器,需要的朋友可以參考下2022-06-06
Python必備技巧之Pandas數(shù)據(jù)合并函數(shù)
Pandas中一共有五個(gè)數(shù)據(jù)合并函數(shù),分別為:concat、append、merge、join、combine,本文詳細(xì)講解這五個(gè)函數(shù)的使用方法,需要的可以參考一下2022-03-03

