【问题标题】:Spyder debugger for Tensorflow用于 Tensorflow 的 Spyder 调试器
【发布时间】:2016-09-22 07:58:37
【问题描述】:

Spyder 带有一个强大的调试器,可用于在执行期间暂停代码并检查变量。

另一方面,Tensorflow 变量不容易检查。有没有办法在 spyder 的 python 控制台中查看它们?

更新: 当我试图回答 anatoly techtonik 的评论时,我决定编写一个虚拟程序来展示这种情况:

import tensorflow as tf

class foo(object):

    def __init__(self, a, b):
        self.a = tf.constant(a)
        self.b = tf.constant(b)
        init = tf.initialize_all_variables()
        self.c = self._foo_add()
        # Launch the session
        self.sess = tf.InteractiveSession()
        self.sess.run(init)

    def _foo_add(self):
        m = tf.add(self.a,self.b)
        return tf.add(m, tf.constant(1))

    def print_foo(self):
        return self.sess.run(self.c)

f = foo(2,3)
print f.print_foo()

如果您在函数_foo_add 的返回语句上放置一个检查点,按下调试按钮并在控制台中输入m.eval(),您可以访问它的值,在这种情况下为5。 我想这回答了我的问题。感谢 anatoly techtonik。

【问题讨论】:

  • 为此,需要有人为对象检查器添加 Tensorflow 对象的特殊渲染。
  • 许多对象在对象检查器中看不到,但可以在调试器控制台中打印它们的值。另一方面,张量似乎有点棘手。
  • 你能张贴一张正在发生的事情以及应该如何做的 gif 图像吗? cockos.com/licecap

标签: python anaconda tensorflow spyder


【解决方案1】:

您是否考虑过使用 tensorflow 调试器

https://www.tensorflow.org/api_guides/python/tfdbg

附带 MNIST 教程

www.tensorflow.org/programmers_guide/debugger

替代方案:Jupyter notebook 似乎有类似的扩展名 (因为这个项目似乎已经不复存在了)

https://github.com/ericjang/tdb

【讨论】:

    猜你喜欢
    • 2022-07-14
    • 2017-06-05
    • 2016-12-16
    • 2020-08-22
    • 2022-06-17
    • 2017-05-31
    • 2021-08-06
    • 2022-07-14
    • 2020-01-10
    相关资源
    最近更新 更多