您好,登錄后才能下訂單哦!
在使用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è)參考,也希望大家多多支持億速云。
免責(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)容。