国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

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

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

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 国产精品免费自拍 | 欧美日韩精品在线 | 久久成人国产精品 | 在线小视频 | 久久逼逼 | 久久久91精品国产一区二区三区 | 97精品久久 | 黄色免费av | 日韩精品视频一区二区三区 | 国产精品久久久久久亚洲调教 | 91国产视频在线 | 在线视频成人 | 国产精品免费av | av在线天堂网 | 精品视频网 | 日韩一区二区中文 | 日韩在线观看中文字幕 | 操操操干干干 | 2015成人永久免费视频 | 91精品国产一区二区三区 | 看免费5xxaaa毛片 | 亚洲精品福利 | 日韩欧美国产精品 | 欧美日韩视频一区二区 | 亚洲日日摸夜夜夜夜夜爽小说 | a视频网站 | 国产在线精品一区二区 | 日韩视频在线一区二区 | 91精品久久久久 | 久久er99热精品一区二区 | 欧美激情精品久久久久久变态 | 欧美精品亚洲精品日韩精品 | 国产一区久久久 | 精品av| 久久男人 | 精品久久久久久久久久久久 | 欧美黄色小视频 | 欧美日韩成人网 | 最新在线国产 | 一区二区三区自拍 | 日本在线观看一区 |