使用Tensorboard 分析cifar10 model_Google

來源:互聯網
上載者:User
背景 Tensorboard 是google推出了一個可視化分析TensorFlow graph 和 運行過程的工具: tensorboard on github cifar10 model 是google發布了一個簡單的基於cifar10 data的的模型: model on the github Tensorboard 的關鍵概念和API summary Ops: Tensorboard需要資料才能可視化和分析模型,所以我們在建立model的時候,需要利用summary Ops把我們需要顯示的資料寫相應的檔案中,稍後Tensorboard會讀取這些檔案。 summary Ops 和tf.matmul, tf.relu 這些Ops是一樣的,我們需要在graph中定義,然後在session中run,資料才會寫到summary 檔案中。這裡有一個例子: mnist_with_summaries tf.summary.FileWriter: 這個class提供了寫入summary 的介面
add_event add_graph add_summary 目前TensorBoard 支援的寫入資訊的Ops:
tf.summary.scalar tf.summary.image tf.summary.audio tf.summary.text 寫入summary的基本步驟 定義summary ops, 比如: tf.summary.scalar, tf.summary.iamge, etc 收集所有的summary ops(你也可以單獨的run每一個summary ops, 但是讓系統幫忙我們run所有的更方便): summary_op=tf.summary.merge_all() 在session裡面run剛剛通過 tf.summary.merge_all匯總的summary op: summary_op 把summary_op啟動並執行結果寫入檔案: tf.summary.FileWriter TensorBoard 一些比較有用的功能 選擇顏色模式(Tensorboard 最左邊的color選項)

我暫時只用到這兩種模式
* structure: 相同的結構的節點會以同樣顏色出現
* device: 在相同裝置上面啟動並執行ops會以相同的顏色出現 Cifar10 model 中的summary Ops: Training model: cifar10_train.py Training model 沒有自己調用 tf.summary.FileWriter 來寫入資訊。而是把這個事情交給 tf.train.MonitoredTrainingSession 來做的。MonitoredTrainningSession 有兩個參數控制summary
save_summaries_steps:每隔多少training step,session寫入summaries到預設的summary saver save_summaries_secs: 每隔多少秒,session寫入summaries到預設summary saver images: cifar10_input.py/_generate_image_and_label_batch
把每次產生的trainning batch 圖片,顯示三張在TensorBoard的image DashBoard 函數_activation_summary:
把model的每一層輸出的tensor以一個histogram展示出來。 計算model輸出的zero fraction,然後把這個數字在scalar dashboard展示出來 函數_add_loss_summaries:
把loss 和 ExponentialMovingAverage 在 scalar dashboard上面展示出來。 函數train(total_loss, global_step),在這個函數中,有一個for 迴圈,把所有的trainable variable, gradients 在histgram dashboard上面展示出來。 還有一些tensorflow buit-in的函數會寫入summaries,這個就不一個個分析了,比如: tf.train.string_input_producer: 會寫入一個名字為”fraction_of_%d_full” % capacity 的scalar 如何使用TensorBoard

命令:tensorboard –logdir=path/to/log-directory logdir: 指向的路徑是 tf.summary.FileWriter 寫入log 的路徑。 如果這個路徑下麵包含了子檔案夾,而這些子檔案夾裡麵包含了不同training run 的日誌,那麼tensorboard會可視化所有的training run. TensorBoard 預設的訪問連接埠是:localhost:6006 Graph 分析 graph overview

data processing

從上圖可以看出,這個graph從string_input_producer 和 FixedLengthRecordReader開始,產生training需要使用的資料。這些資料(image,label)最後匯總到shuffle_batch,然後有三個node會使用這些資料:
* conv1: our CNN network.
* gradients: 計算gradient
* cross entropy: 計算cross entropy cross entropy

Training nodes

為了避免graph過於複雜,tensorboard引入了auxiliary node的功能:一些高階的節點,會被移到graph右邊的auxiliary 區。training nodes就是被放在這邊了,比如conv1。 我們可以點擊conv1 左邊或者右邊的表徵圖跳轉到有連結的node上面 其他DashBoard Scalar, etc

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.