一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

腳本之家,腳本語言編程技術及教程分享平臺!
分類導航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務器之家 - 腳本之家 - Python - TensorFlow可視化工具TensorBoard默認圖與自定義圖

TensorFlow可視化工具TensorBoard默認圖與自定義圖

2022-01-26 10:46_睿智_ Python

這篇文章主要介紹了TensorFlow可視化工具TensorBoard默認圖與自定義圖的使用操作示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助

一、圖

圖:數據(張量Tenrsor)+ 操作(節點Operation) (靜態)

圖可以用:1、默認圖;2、自定義圖。

1、默認圖

查看默認圖的方式:

  • 1、調用方法:tf.get_default_graph()
  • 2、查看屬性:.graph

1、調用方法查看默認圖屬性

# 方法一:調用方法
  default = tf.get_default_graph()
  print('default:', default)

TensorFlow可視化工具TensorBoard默認圖與自定義圖

2、.graph查看圖屬性

# 方法二:查看屬性
  # 查看節點屬性
  print('a的屬性:', a.graph)
  print('c的屬性:', c.graph)
  # 查看會話屬性
  print('會話sess的圖屬性:', sess.graph)

TensorFlow可視化工具TensorBoard默認圖與自定義圖

TensorFlow可視化工具TensorBoard默認圖與自定義圖

可以發現這些圖的地址都是同一個地址,是因為它們都是默認使用了默認圖。

代碼

# 查看默認圖
def View_Graph():
  # 方法一:調用方法
  default = tf.get_default_graph()
  print('default:', default)   
  # 方法二:查看屬性
  # 查看節點屬性
  print('a的屬性:', a.graph)
  print('c的屬性:', c.graph)
  # 查看會話屬性
  print('會話sess的圖屬性:', sess.graph)

2、自定義圖(創建圖)

1、創建自定義圖

# 1 創建自定義圖
  new_graph = tf.Graph()
  print(new_graph)

TensorFlow可視化工具TensorBoard默認圖與自定義圖

2、創建靜態圖

# 2 創建靜態圖(張量和節點)
  with new_graph.as_default():
      a = tf.constant(10)
      b = tf.constant(20)
      c = a + b
      print(c)

3、開啟會話(運行)

# 3 開啟對話(運行)
  with tf.Session(graph=new_graph) as sess:
      print('c=', sess.run(c))

TensorFlow可視化工具TensorBoard默認圖與自定義圖

4、查看自定義圖

# 4 查看自定義圖
  View_Graph(a, b, c, sess)
# 查看圖
def View_Graph(a, b, c, sess):
  # 方法一:調用方法
  default = tf.get_default_graph()
  print('default:', default)

  # 方法二:查看屬性
  # 查看節點屬性
  print('a的屬性:', a.graph)
  print('c的屬性:', c.graph)
  # 查看會話屬性
  print('會話sess的圖屬性:', sess.graph)

TensorFlow可視化工具TensorBoard默認圖與自定義圖

代碼

# 自定義圖
def Create_myGraph():
  # 1 創建自定義圖
  new_graph = tf.Graph()
  print(new_graph)
  
  # 2 創建靜態圖(張量和節點)
  with new_graph.as_default():
      a = tf.constant(10)
      b = tf.constant(20)
      c = a + b
      print(c)
  
  # 3 開啟對話(運行)
  with tf.Session(graph=new_graph) as sess:
      print('c=', sess.run(c))

  # 4 查看自定義圖
  View_Graph(a, b, c, sess)

 

二、TensorBoard可視化

1、可視化處理

tf.summary.FileWriter(path, graph=)
# 可視化
      tf.summary.FileWriter("C:\\Users\\Administrator\\Desktop\\summary", graph=sess.graph)            #path                                            圖

2、 打開TensorBoard

在cmd中操作:

1、先移到文件夾的前面

cd C://Users//Administrator//Desktop

2、 打開TensorBoard(從文件中獲取數據)

tensorboard --logdir=summary

TensorFlow可視化工具TensorBoard默認圖與自定義圖

3、打開給定的網址

http://localhost:6006/(cmd中給的網址)

得到可視化結果:

TensorFlow可視化工具TensorBoard默認圖與自定義圖

 

總代碼

import tensorflow as tf
# 創建TensorFlow框架
def Create_Tensorflow():
  # 圖(靜態)
  a = tf.constant(2)  # 數據1(張量)
  b = tf.constant(6)  # 數據2(張量)
  c = a + b  # 操作(節點)   
  # 會話(執行)
  with tf.Session() as sess:
      print('c=', sess.run(c))
      # 可視化
      tf.summary.FileWriter("C:\\Users\\Administrator\\Desktop\\summary", graph=sess.graph) 
  # 查看默認圖
  View_Graph(a, b, c, sess) 
# 查看圖
def View_Graph(a, b, c, sess):
  # 方法一:調用方法
  default = tf.get_default_graph()
  print('default:', default) 
  # 方法二:查看屬性
  # 查看節點屬性
  print('a的屬性:', a.graph)
  print('c的屬性:', c.graph)
  # 查看會話屬性
  print('會話sess的圖屬性:', sess.graph) 
# 自定義圖
def Create_myGraph():
  # 1 創建自定義圖
  new_graph = tf.Graph()
  print(new_graph)    
  # 2 創建靜態圖(張量和節點)
  with new_graph.as_default():
      a = tf.constant(10)
      b = tf.constant(20)
      c = a + b
      print(c)   
  # 3 開啟對話(運行)
  with tf.Session(graph=new_graph) as sess:
      print('c=', sess.run(c)) 
  # 4 查看自定義圖
  View_Graph(a, b, c, sess) 
if __name__ == '__main__':
  # 創建TensorFlow框架
  Create_Tensorflow() 
  # 創建自定義圖
  Create_myGraph()

以上就是TensorFlow可視化工具TensorBoard默認圖與自定義圖 的詳細內容,更多關于TensorFlow可視化TensorBoard工具的資料請關注服務器之家其它相關文章!

原文鏈接:https://blog.csdn.net/great_yzl/article/details/120486792

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 欧美一级xxx| 91久久综合九色综合欧美98 | 性xxxx欧美高清 | 欧美特黄一级大片 | 男人与雌性宠物交啪啪小说 | 国产精品自在线拍 | 99re精品在线 | 免费jizz在在线播放国产 | a在线观看欧美在线观看 | 午夜AV亚洲一码二中文字幕青青 | 日本中文字幕在线观看视频 | 99久久精品免费看国产一区二区 | 91制片厂果冻传媒杨柳作品 | 色视频国产 | 亚洲国产精品综合久久网络 | 不知火舞被c视频在线播放 不卡一区二区三区卡 | 国产真实偷乱视频在线观看 | 我将她侵犯1~6樱花动漫在线看 | 精品一区二区三区五区六区 | 亚洲欧美日韩中文高清一 | 青青国产成人久久91网 | 国产欧美日韩亚洲精品区2345 | 日本激情网 | 青草免费在线观看 | 日韩在线视精品在亚洲 | 精品久久久噜噜噜久久久app | 大肚孕妇的高h辣文 | 青春草在线观看视频 | 亚洲精品一区二区三区中文字幕 | 日本美女动态图片 | 青青草国产免费久久久91 | 好骚好紧 | 免费尤物视频 | 99综合在线 | 欧美草比视频 | 媳妇和公公小说 | aigao视频 | 国产成人精品免费大全 | 欧美精品99 | 国语刺激对白勾搭视频在线观看 | 精品国产人妻国语 |