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

tensorflow 實(shí)現(xiàn)從checkpoint中獲取graph信息

 更新時(shí)間:2020年02月10日 15:13:02   作者:qq_28808697  
今天小編就為大家分享一篇tensorflow 實(shí)現(xiàn)從checkpoint中獲取graph信息,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

代碼:

import tensorflow as tf
 
sess = tf.Session()
check_point_path = 'variables' 
saver = tf.train.import_meta_graph('variables/save_variables.ckpt.meta')
 
saver.restore(sess, tf.train.latest_checkpoint(check_point_path))
 
graph = tf.get_default_graph()
 
#print(graph.get_operations())
 
#with open('op.txt','a') as f:
# f.write(str(graph.get_operations()))
op1 = graph.get_tensor_by_name('fully_connected/biases:0')
print(op1)

使用函數(shù)graph.get_operations()獲取ckpt.meta中保存的graph中的所有operation,而tensor_name為'op_name:0'。

然后使用graph.get_tensor_by_name('op_name:0') 獲取tensor信息。

代碼從ckpt文件中獲取保存的variable的數(shù)據(jù)(tensor的name和value):

import os
import tensorflow as tf
from tensorflow.python import pywrap_tensorflow
check_point_path = 'variables'
#checkpoint_path = os.path.join(logs_train_dir, 'model.ckpt')
ckpt = tf.train.get_checkpoint_state(checkpoint_dir=check_point_path)
checkpoint_path = os.path.join('.', ckpt.model_checkpoint_path)
#print(ckpt.model_checkpoint_path)
reader = pywrap_tensorflow.NewCheckpointReader(checkpoint_path)
var_to_shape_map = reader.get_variable_to_shape_map()
for key in var_to_shape_map:
 print("tensor_name: ", key)
 #print(reader.get_tensor(key))

法二:

from tensorflow.python.tools.inspect_checkpoint import print_tensors_in_checkpoint_file
 
print_tensors_in_checkpoint_file("variables/save_variables.ckpt",tensor_name='', all_tensors=False, all_tensor_names=False)

注意:tf.train.latest_checkpoint(check_point_path) 方法用來(lái)獲取最后一次ckeckpoint的路徑,等價(jià)于

ckpt = tf.train.get_checkpoint_state(check_point_path)
ckpt.model_checkpoint_path

不能將tf.train.latest_checkpoint與tf.train.get_checkpoint_state 搞混了

以上這篇tensorflow 實(shí)現(xiàn)從checkpoint中獲取graph信息就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • python中的正斜杠與反斜杠實(shí)例驗(yàn)證

    python中的正斜杠與反斜杠實(shí)例驗(yàn)證

    這篇文章主要介紹了python中的正斜杠與反斜杠實(shí)例驗(yàn)證,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-03-03
  • Python中super關(guān)鍵字用法實(shí)例分析

    Python中super關(guān)鍵字用法實(shí)例分析

    這篇文章主要介紹了Python中super關(guān)鍵字用法,實(shí)例分析了super關(guān)鍵字的功能及相關(guān)使用技巧,需要的朋友可以參考下
    2015-05-05
  • Ubuntu下Python2與Python3的共存問(wèn)題

    Ubuntu下Python2與Python3的共存問(wèn)題

    Linux系統(tǒng)一般自帶Python,有時(shí)候又自己下載了Python,因此有可能Python2和Python3同時(shí)存在。那么當(dāng)我們?cè)赥erminal鍵入python的時(shí)候,會(huì)調(diào)出哪個(gè)Python呢?本文即解決這個(gè)問(wèn)題
    2018-10-10
  • Python 16進(jìn)制與中文相互轉(zhuǎn)換的實(shí)現(xiàn)方法

    Python 16進(jìn)制與中文相互轉(zhuǎn)換的實(shí)現(xiàn)方法

    今天小編就為大家分享一篇Python 16進(jìn)制與中文相互轉(zhuǎn)換的實(shí)現(xiàn)方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-07-07
  • python mysql中in參數(shù)化說(shuō)明

    python mysql中in參數(shù)化說(shuō)明

    這篇文章主要介紹了python mysql中in參數(shù)化說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-06-06
  • python實(shí)現(xiàn)mysql的單引號(hào)字符串過(guò)濾方法

    python實(shí)現(xiàn)mysql的單引號(hào)字符串過(guò)濾方法

    這篇文章主要介紹了python實(shí)現(xiàn)mysql的單引號(hào)字符串過(guò)濾方法,以一個(gè)較為詳細(xì)的實(shí)例形式分析了Python針對(duì)MySQL的操作及字符串過(guò)濾的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-11-11
  • 詳細(xì)解析Python中的變量的數(shù)據(jù)類型

    詳細(xì)解析Python中的變量的數(shù)據(jù)類型

    這篇文章主要介紹了詳細(xì)解析Python中的變量的數(shù)據(jù)類型,是Python學(xué)習(xí)當(dāng)中的基礎(chǔ)知識(shí),需要的朋友可以參考下
    2015-05-05
  • python處理html轉(zhuǎn)義字符的方法詳解

    python處理html轉(zhuǎn)義字符的方法詳解

    這篇文章主要介紹了python處理html轉(zhuǎn)義字符的方法,結(jié)合實(shí)例形式較為詳細(xì)的分析了Python針對(duì)常見(jiàn)HTML轉(zhuǎn)義字符處理技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2016-07-07
  • Python連接數(shù)據(jù)庫(kù)進(jìn)行數(shù)據(jù)查詢的操作代碼

    Python連接數(shù)據(jù)庫(kù)進(jìn)行數(shù)據(jù)查詢的操作代碼

    這篇文章主要介紹了Python連接數(shù)據(jù)庫(kù)進(jìn)行數(shù)據(jù)查詢的操作代碼,本文給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧
    2024-06-06
  • 簡(jiǎn)單聊聊PyTorch里面的torch.nn.Parameter()

    簡(jiǎn)單聊聊PyTorch里面的torch.nn.Parameter()

    torch.nn.parameter是一個(gè)被用作神經(jīng)網(wǎng)絡(luò)模塊參數(shù)的tensor,這是一種tensor的子類,下面這篇文章主要給大家介紹了關(guān)于PyTorch里面的torch.nn.Parameter()的相關(guān)資料,需要的朋友可以參考下
    2022-02-02

最新評(píng)論

广丰县| 鄢陵县| 嘉义市| 湘乡市| 修武县| 大渡口区| 盖州市| 南通市| 博兴县| 丰顺县| 洪湖市| 启东市| 新河县| 贺兰县| 阿图什市| 乌鲁木齐市| 静宁县| 天门市| 广宗县| 西林县| 绥中县| 五指山市| 分宜县| 河北省| 新竹市| 福州市| 金溪县| 施秉县| 桐乡市| 天全县| 裕民县| 哈尔滨市| 济南市| 新竹市| 乌拉特中旗| 寿阳县| 嘉祥县| 兴安县| 博湖县| 长岛县| 余庆县|