如何在Tensorflow中的tf.estimator上使用tensorflow调试工具tfdbg? [英] How to use tensorflow debugging tool tfdbg on tf.estimator in Tensorflow?
问题描述
我正在使用Tensorflow 1.4版,并且想调试 train()
函数。
I am working with Tensorflow version 1.4, and I want to debug my train()
function.
在此链接中 https://www.tensorflow.org/programmers_guide/debugger#debugging_tf-learn_estimators_and_experiments
有一种方法可以用于 tf.contrib.learn Estimators
,但是我可以找不到一种方法来适应它(1.4版中的新功能) tf.estimator
。
there is a way to do it for tf.contrib.learn Estimators
, but I can not find a way to adapt it to the (new in version 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)
但是我遇到了这个错误:
But I am running into this error:
> --------------------------------------------------------------------------- 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
有人可以指出我正确的方向吗?
Can someone point me in the right direction?
推荐答案
默认设置为在命令行中工作,如果您使用Pycharm等IDE,最简单的解决方案是更改UI类型。
The default is set for working in command line, if you use IDE such as Pycharm the simplest solution is to change UI type.
尝试:
hooks = [tf_debug.LocalCLIDebugHook(ui_type="readline")]
而不是:
hooks = [tf_debug.LocalCLIDebugHook()]
如果您使用Pycharm ,添加到配置参数--debug
In case you use Pycharm, add to the configuration parameters --debug
这篇关于如何在Tensorflow中的tf.estimator上使用tensorflow调试工具tfdbg?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!