溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Tensorflow: 從checkpoint文件中讀取tensor方式

發(fā)布時(shí)間:2020-08-30 21:13:29 來源:腳本之家 閱讀:374 作者:noirblack 欄目:開發(fā)技術(shù)

在使用pre-train model時(shí)候,我們需要restore variables from checkpoint files.

經(jīng)常出現(xiàn)在checkpoint 中找不到”Tensor name not found”.

這時(shí)候需要查看一下ckpt中到底有哪些變量

import os
from tensorflow.python import pywrap_tensorflow

checkpoint_path = os.path.join(model_dir, "model.ckpt")
# Read data from checkpoint file
reader = pywrap_tensorflow.NewCheckpointReader(checkpoint_path)
var_to_shape_map = reader.get_variable_to_shape_map()
# Print tensor name and values
for key in var_to_shape_map:
 print("tensor_name: ", key)
 print(reader.get_tensor(key))

可以顯示ckpt中的tensor名字和值,當(dāng)然也可以用pycharm調(diào)試。

以上這篇Tensorflow: 從checkpoint文件中讀取tensor方式就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持億速云。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI