如何调试Tensorflow Network每个输入样本的权重/输出/成本



我制作了一个张量流模型。但总是因为某种原因而失去NAN。我想知道如何调试和查看每个张量中的每个值。

例如:-

 out = tf.add(tf.matmul(outputs[-1], _weights['out']), _biases['out'])

在运行时,我想查看这个张量中的值,看看哪里出了问题。我在这个后中发现了类似的东西

他们在哪里做类似的事情

out = tf.add(tf.matmul(outputs[-1], _weights['out']), _biases['out'])
out = tf.Print(out, [out], message="This is softmax Output: ")

但这就像一样

I tensorflow/core/kernels/logging_ops.cc:79] This is softmax Output: [2.148583e-08 5.9002307e-08 -9.90654e-08...]
I tensorflow/core/kernels/logging_ops.cc:79] This is softmax Output: [nan nan nan...]
I tensorflow/core/kernels/logging_ops.cc:79] This is softmax Output: [nan nan nan...]
Iter 64, Minibatch Loss= nan, Training Accuracy= 0.01562
Testing Accuracy: 0.0
I tensorflow/core/kernels/logging_ops.cc:79] This is softmax Output: [nan nan nan...]
I tensorflow/core/kernels/logging_ops.cc:79] This is softmax Output: [nan nan nan...]
I tensorflow/core/kernels/logging_ops.cc:79] This is softmax Output: [nan nan nan...]
I tensorflow/core/kernels/logging_ops.cc:79] This is softmax Output: [nan nan nan...]

这并没有那么有用,因为我无法查看所有的值。我想知道是否有逐步调试选项?

TensorFlow现在有一个名为tfdbg的内置调试器。它公开了图中的中间张量,以及图的结构,这将使您更容易调试这类问题。与打印操作相比,它需要更少的代码更改,并提供更好的图形覆盖率。

请在master HEAD上查看其文档/教程:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/how_tos/debugger/index.md

tf.Print()如果传递summarize可选参数,将显示更多结果。例如,summarize=100将显示张量的前100个元素。

API参考

(不确定提问时该功能是否存在)

最新更新