Python 如何在tensorflow中的tf.estimator上使用tensorflow调试工具tfdbg?

Python 如何在tensorflow中的tf.estimator上使用tensorflow调试工具tfdbg?,python,debugging,tensorflow,tensorflow-estimator,Python,Debugging,Tensorflow,Tensorflow Estimator,我正在使用Tensorflow 1.4版,我想调试我的train()函数 在此链接中 有一种方法可以用于tf.contrib.learn估计器,但我找不到一种方法使其适应(1.4版中的新版本)tf.estimator 这就是我尝试过的: from tensorflow.python import debug as tf_debug # Create an estimator my_estimator = tf.estimator.Estimator(model_fn=model_fn,

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

在此链接中

有一种方法可以用于
tf.contrib.learn估计器
,但我找不到一种方法使其适应(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
-------------------------------------------------------------错误
回溯(最近的呼叫)
>最后)在()
>       7 
>8#列车
>--->9我的估算器.train(input\u fn=train\u input\u fn,步长=10,hooks=hooks)
> 
[...]
> 
>/root/anaconda3/lib/python3.6/site-packages/tensorflow/python/debug/cli/curses\u ui.py
>在屏幕中启动(自启动,启动时启用鼠标)
>     443 
>444诅咒
>-->445个诅咒。cbreak()
>446自动键盘(1)
>     447 
> 
>错误:cbreak()返回错误

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

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

尝试:

而不是:

hooks = [tf_debug.LocalCLIDebugHook()]      

如果您使用Pycharm,请添加到配置参数--debug

我正在使用Jupyter笔记本,是的,它正在使用您的解决方案。谢谢
hooks = [tf_debug.LocalCLIDebugHook()]