最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2021年10月16日 16:46:25   作者:_睿智_  
這篇文章主要介紹了TensorFlow可視化工具TensorBoard默認圖與自定義圖的使用操作示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助

一、圖

圖:數(shù)據(jù)(張量Tenrsor)+ 操作(節(jié)點Operation) (靜態(tài))

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

1、默認圖

查看默認圖的方式:

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

1、調(diào)用方法查看默認圖屬性

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

2、.graph查看圖屬性

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

可以發(fā)現(xiàn)這些圖的地址都是同一個地址,是因為它們都是默認使用了默認圖。

代碼

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

2、自定義圖(創(chuàng)建圖)

1、創(chuàng)建自定義圖

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

2、創(chuàng)建靜態(tài)圖

 # 2 創(chuàng)建靜態(tài)圖(張量和節(jié)點)
    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))

4、查看自定義圖

# 4 查看自定義圖
    View_Graph(a, b, c, sess)
# 查看圖
def View_Graph(a, b, c, sess):
    # 方法一:調(diào)用方法
    default = tf.get_default_graph()
    print('default:', default)
 
    # 方法二:查看屬性
    # 查看節(jié)點屬性
    print('a的屬性:', a.graph)
    print('c的屬性:', c.graph)
    # 查看會話屬性
    print('會話sess的圖屬性:', sess.graph)

代碼

# 自定義圖
def Create_myGraph():
    # 1 創(chuàng)建自定義圖
    new_graph = tf.Graph()
    print(new_graph)
    
    # 2 創(chuàng)建靜態(tài)圖(張量和節(jié)點)
    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(從文件中獲取數(shù)據(jù))

tensorboard --logdir=summary

3、打開給定的網(wǎng)址

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

得到可視化結(jié)果:

總代碼

import tensorflow as tf
# 創(chuàng)建TensorFlow框架
def Create_Tensorflow():
    # 圖(靜態(tài))
    a = tf.constant(2)  # 數(shù)據(jù)1(張量)
    b = tf.constant(6)  # 數(shù)據(jù)2(張量)
    c = a + b  # 操作(節(jié)點)   
    # 會話(執(zhí)行)
    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):
    # 方法一:調(diào)用方法
    default = tf.get_default_graph()
    print('default:', default) 
    # 方法二:查看屬性
    # 查看節(jié)點屬性
    print('a的屬性:', a.graph)
    print('c的屬性:', c.graph)
    # 查看會話屬性
    print('會話sess的圖屬性:', sess.graph) 
# 自定義圖
def Create_myGraph():
    # 1 創(chuàng)建自定義圖
    new_graph = tf.Graph()
    print(new_graph)    
    # 2 創(chuàng)建靜態(tài)圖(張量和節(jié)點)
    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__':
    # 創(chuàng)建TensorFlow框架
    Create_Tensorflow() 
    # 創(chuàng)建自定義圖
    Create_myGraph()

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

相關文章

最新評論

油尖旺区| 黑水县| 惠安县| 永康市| 溆浦县| 凤庆县| 九江市| 呼伦贝尔市| 岑溪市| 宁国市| 武陟县| 依兰县| 思茅市| 建水县| 武邑县| 潜江市| 离岛区| 长宁区| 开封县| 珲春市| 临颍县| 友谊县| 汉沽区| 大厂| 边坝县| 壤塘县| 同德县| 江陵县| 和政县| 邵东县| 鄱阳县| 富蕴县| 刚察县| 兴山县| 贵定县| 马鞍山市| 宜宾市| 五台县| 久治县| 嘉善县| 木里|