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

TensorFlow可視化工具TensorBoard默認(rèn)圖與自定義圖

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

一、圖

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

圖可以用:1、默認(rèn)圖;2、自定義圖。

1、默認(rèn)圖

查看默認(rèn)圖的方式:

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

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

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

2、.graph查看圖屬性

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

可以發(fā)現(xiàn)這些圖的地址都是同一個(gè)地址,是因?yàn)樗鼈兌际悄J(rèn)使用了默認(rèn)圖。

代碼

# 查看默認(rèn)圖
def View_Graph():
    # 方法一:調(diào)用方法
    default = tf.get_default_graph()
    print('default:', default)   
    # 方法二:查看屬性
    # 查看節(jié)點(diǎn)屬性
    print('a的屬性:', a.graph)
    print('c的屬性:', c.graph)
    # 查看會(huì)話屬性
    print('會(huì)話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é)點(diǎn))
    with new_graph.as_default():
        a = tf.constant(10)
        b = tf.constant(20)
        c = a + b
        print(c)

3、開啟會(huì)話(運(yùn)行)

# 3 開啟對(duì)話(運(yùn)行)
    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é)點(diǎn)屬性
    print('a的屬性:', a.graph)
    print('c的屬性:', c.graph)
    # 查看會(huì)話屬性
    print('會(huì)話sess的圖屬性:', sess.graph)

代碼

# 自定義圖
def Create_myGraph():
    # 1 創(chuàng)建自定義圖
    new_graph = tf.Graph()
    print(new_graph)
    
    # 2 創(chuàng)建靜態(tài)圖(張量和節(jié)點(diǎn))
    with new_graph.as_default():
        a = tf.constant(10)
        b = tf.constant(20)
        c = a + b
        print(c)
    
    # 3 開啟對(duì)話(運(yùn)行)
    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é)點(diǎn))   
    # 會(huì)話(執(zhí)行)
    with tf.Session() as sess:
        print('c=', sess.run(c))
        # 可視化
        tf.summary.FileWriter("C:\\Users\\Administrator\\Desktop\\summary", graph=sess.graph) 
    # 查看默認(rèn)圖
    View_Graph(a, b, c, sess) 
# 查看圖
def View_Graph(a, b, c, sess):
    # 方法一:調(diào)用方法
    default = tf.get_default_graph()
    print('default:', default) 
    # 方法二:查看屬性
    # 查看節(jié)點(diǎn)屬性
    print('a的屬性:', a.graph)
    print('c的屬性:', c.graph)
    # 查看會(huì)話屬性
    print('會(huì)話sess的圖屬性:', sess.graph) 
# 自定義圖
def Create_myGraph():
    # 1 創(chuàng)建自定義圖
    new_graph = tf.Graph()
    print(new_graph)    
    # 2 創(chuàng)建靜態(tài)圖(張量和節(jié)點(diǎn))
    with new_graph.as_default():
        a = tf.constant(10)
        b = tf.constant(20)
        c = a + b
        print(c)   
    # 3 開啟對(duì)話(運(yùn)行)
    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默認(rèn)圖與自定義圖 的詳細(xì)內(nèi)容,更多關(guān)于TensorFlow可視化TensorBoard工具的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評(píng)論

三江| 义乌市| 新宾| 鄂托克前旗| 青浦区| 溧阳市| 富宁县| 汨罗市| 寻乌县| 乌拉特前旗| 繁昌县| 都安| 黔江区| 聊城市| 柞水县| 丹寨县| 缙云县| 雅安市| 社会| 亳州市| 独山县| 临沂市| 镇宁| 嵊州市| 桦川县| 舒城县| 彰武县| 福安市| 广汉市| 海口市| 思茅市| 盐池县| 新宾| 佳木斯市| 临颍县| 新蔡县| 湖州市| 明水县| 阳新县| 奉化市| 长子县|