【问题标题】:How to use tensorflow debugging tool tfdbg on tf.estimator in Tensorflow?如何在 TensorFlow 中的 tf.estimator 上使用 TensorFlow 调试工具 tfdbg?
【发布时间】:2017-12-15 13:48:26
【问题描述】:

我正在使用 Tensorflow 1.4 版,我想调试我的 train() 函数。

在此链接https://www.tensorflow.org/programmers_guide/debugger#debugging_tf-learn_estimators_and_experiments

有一种方法可以为tf.contrib.learn Estimators 做到这一点,但我找不到一种方法来适应(1.4 版中的新功能)tf.estimator

这是我尝试过的:

from tensorflow.python import debug as tf_debug

# Create an estimator
my_estimator = tf.estimator.Estimator(model_fn=model_fn, 
                                      params=model_params,
                                      model_dir='/tb_dir',
                                      config=config_estimator)

# Create a LocalCLIDebugHook and use it as a hook when calling train().
hooks = [tf_debug.LocalCLIDebugHook()]

# Train
my_estimator.train(input_fn=train_input_fn, steps=10,hooks=hooks)

但是我遇到了这个错误:

> --------------------------------------------------------------------------- error 
Traceback (most recent call
> last) <ipython-input-14-71325f3c8f14> in <module>()
>       7 
>       8 # Train
> ----> 9 my_estimator.train(input_fn=train_input_fn, steps=10,hooks=hooks)
> 
[...]
> 
> /root/anaconda3/lib/python3.6/site-packages/tensorflow/python/debug/cli/curses_ui.py
> in _screen_launch(self, enable_mouse_on_start)
>     443 
>     444     curses.noecho()
> --> 445     curses.cbreak()
>     446     self._stdscr.keypad(1)
>     447 
> 
> error: cbreak() returned ERR

有人能指出正确的方向吗?

【问题讨论】:

    标签: python debugging tensorflow tensorflow-estimator


    【解决方案1】:

    默认设置为在命令行中工作,如果您使用 IDE,例如 Pycharm,最简单的解决方案是更改 UI 类型。

    试试:

    hooks = [tf_debug.LocalCLIDebugHook(ui_type="readline")]
    

    代替:

    hooks = [tf_debug.LocalCLIDebugHook()]      
    

    如果你使用Pycharm,在配置参数中添加--debug

    【讨论】:

    • 我正在使用 Jupyter 笔记本,是的,它正在使用您的解决方案。谢谢
    猜你喜欢
    • 2018-09-16
    • 1970-01-01
    • 2018-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多