[英]How to check all the values of trained variables in my tensorflow neural network?
I already have my saved checkpoints, and I can use them to make predictions. 我已经保存了检查点,可以使用它们进行预测。 However, I just want to take a look into my trained variables and know what exact values they are. 但是,我只想看一下我训练有素的变量,并知道它们是什么确切值。
I am now using print_tensors_in_checkpoint_file from tensorflow.python.tools.inspect_checkpoint. 我现在正在使用来自tensorflow.python.tools.inspect_checkpoint的print_tensors_in_checkpoint_file。
I am also using sys.stdout to store the output into a txt file. 我还使用sys.stdout将输出存储到txt文件中。
My current code looks like this: 我当前的代码如下所示:
from tensorflow.python.tools.inspect_checkpoint import print_tensors_in_checkpoint_file
import sys
def peekckpt(filePath):
print_tensors_in_checkpoint_file(filePath,None,True)
sys.stdout = open("tmp.txt",'w')
peekckpt("/save/model.ckpt-10000")
However, it won't display all the details. 但是,它不会显示所有详细信息。 In tmp.txt, some variables are represented in the form of ellipsis (maybe because there are too many of them), for example: 在tmp.txt中,某些变量以省略号的形式表示(也许是因为它们太多了),例如:
tensor_name: fully_connected_1/weights
[[ 0.01625621 -0.01740162 0.04686484 ... -0.02088195 -0.02621443
0.00247668]
[-0.00319242 -0.04545522 0.01150012 ... 0.00360141 -0.00241386
-0.04921322]
[ 0.04347562 0.00918857 0.00323885 ... 0.01275046 -0.06735339
0.02492226]
So, is there any way I can get rid of this ellipsis issue and let print_tensors_in_checkpoint_file() print all the variables? 因此,有什么办法可以消除这个省略号问题,并让print_tensors_in_checkpoint_file()打印所有变量?
Add the following before my original code: 在我的原始代码之前添加以下内容:
import numpy as np
np.set_printoptions(threshold=np.nan)
This will work. 这将起作用。 It took around 30s - 40s, and finally I got a 81MB txt file. 大约花了30到40秒钟,最后我得到了一个81MB的txt文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.