国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

TensorBoard 計算圖的可視化實現

2020-02-15 18:24:08
字體:
來源:轉載
供稿:網友

簡介

tensorflow 配套的可視化工具, 將你的計算圖畫出來.

當訓練一個巨大的網絡的時候, 計算圖既復雜又令人困惑. TensorBoard 提供了一系列的組件, 可以看到 learning rate 的變化, 看到 objective function 的變化.

tfboard 讀取 tf 運行時你記下的 events files, 來進行可視化. 這些 events files 包含了你記下的 summary data, 它是 protobuffer 格式, 并非文本文件.

推薦使用 Estimator 風格.

類與方法

在 tf.estimator 框架下, 可以直接用 tf.summary.scalar() 這樣的方法, 不必顯式地創建writer并調用writer.add_summary()

tensorflow.python.summary.writer.writer.FileWriter(SummaryToEventTransformer)

類.

__init__(self, logdir, graph=None,...)

構造函數, Creates a FileWriter and an event file.

tensorflow.python.summary.summary

模塊.

scalar(name, tensor, ..) Outputs a Summary protocol buffer containing a single scalar value.

histogram(name, values, collections=None, family=None) Adding a histogram summary makes it possible to visualize your data's distribution in TensorBoard.

image

作圖, 對于grap-scale 圖來講, 0表示全黑, 255表示全白.

api, image(name, tensor, max_outputs=3, collections=None, family=None) Outputs a Summary protocol buffer with images. images are built from tensor which must be 4-D with shape [batch_size, height, width, channels] and where channels can be:

1.1-tensor is interpreted as Grayscale.

2.3-tensor is interpreted as RGB.

3.4-tensor is interpreted as RGBA.

tensor為float: 此時, tf會內部作正規化處理, 轉換到[0,255](解析 tf_events 即可驗證), float通常對應于 softm 之后的概率, 值域為[0,1].

tensor為uint8, 保持不變, tf 不作任何內部轉換.

attention 可視化, attention 的權重會作 soft-max 處理, 通常img顯示的效果是, 一行看下來有深有淺, 顏色越白weight越大. 但有時后tf內部正規化不符合預期, 出現一行全白的情況, 穩妥起見自己轉unit類型.

打開web頁面

在命令行中 敲tensorboard --logdir=D:/tf_models/iris, 根據提示打開URL即可.

比如我的為http://yichu-amd:6006/.

效果截圖

圖3-1 logdir中的文件

圖3-2 炫酷的可視化效果

figure 3-3 計算圖的可視化

給出一些建議:

網絡也是分模塊,有結構的, 合理使用 scope 可以讓計算圖清晰優雅.

有些tensor來自dataset, 有些來自api中op操作的輸出, 本身沒有明確的名字, 此時用x=tf.identity(x,'name') 給tensor起名字, 便于計算圖中定位. 圖3-3 中的 memory 就是 encoder 的輸出的tensor.

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 科技| 即墨市| 屏南县| 新宁县| 宜川县| 永仁县| 仁布县| 中卫市| 吕梁市| 日照市| 社会| 石景山区| 临沂市| 虞城县| 阿拉善左旗| 福贡县| 玉田县| 谷城县| 德清县| 庆安县| 鄂温| 察哈| 当涂县| 梧州市| 贡嘎县| 大新县| 德昌县| 石林| 五峰| 遵化市| 招远市| 常熟市| 伊吾县| 唐河县| 札达县| 花垣县| 辉南县| 迭部县| 和政县| 晋城| 乌恰县|