简体   繁体   English

如何检查我的张量流神经网络中所有训练变量的值?

[英]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.

相关问题 Tensorflow:如何将Tensor馈送到经过训练的神经网络? - Tensorflow: How to feed a Tensor to a trained neural network? 如何检查受过训练的神经网络的预测输出 - How to check the predicted output of a trained Neural Network Python / Tensorflow - 我已经训练了卷积神经网络,如何测试它? - Python/Tensorflow - I have trained the convolutional neural network, how to test it? 如何将训练有素的稳定基线/TensorFlow 神经网络导出到 MATLAB? - How to export trained stable-baselines/TensorFlow neural network to MATLAB? 实施人工神经网络时,如何减少训练值中的误差? - How can I reduce the error in my trained values while implementing Artificial Neural Network? 使用Python中的Tensorflow测试受过训练的神经网络 - Testing the trained neural network using tensorflow in Python 如何检查keras分类器/神经网络的训练类? - how to check the classes a keras classifier/Neural Network is trained on? 如何运行我训练有素的人工神经网络 model? - How to run my trained Artificial Neural Network model? 如何在我的神经网络输出中打印所有值? - How to print all the values out in my Neural Network output? 如何使用经过训练的神经网络(Tensorflow 2.0,回归分析)预测新数据? - How to predict new data with a trained neural network (Tensorflow 2.0, regression analysis)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM