GetControlPivot()在compute_gradients期间返回None

时间:2018-08-29 20:28:51

标签: python python-3.x debugging tensorflow

在调用compute_gradients时,出现以下错误

File "...../tensorflow/python/ops/control_flow_ops.py", line 2430, in AddOp
  self._AddOpInternal(op)
File "...../tensorflow/python/ops/control_flow_ops.py", line 2467, in _AddOpInternal
  for x in external_inputs if x.outputs]
File "...../tensorflow/python/ops/control_flow_ops.py", line 2467, in <listcomp>
  for x in external_inputs if x.outputs]
File "...../tensorflow/python/ops/array_ops.py", line 79, in identity
  return gen_array_ops.identity(input, name=name)
File "...../tensorflow/python/ops/gen_array_ops.py", line 3263, in identity
  "Identity", input=input, name=name)
File "...../tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
  op_def=op_def)
File "...../tensorflow/python/framework/ops.py", line 3414, in create_op
  op_def=op_def)
File "...../tensorflow/python/framework/ops.py", line 1782, in __init__
  self._control_flow_post_processing()
File "...../tensorflow/python/framework/ops.py", line 1793, in _control_flow_post_processing
  self._control_flow_context.AddOp(self)
File "...../tensorflow/python/ops/control_flow_ops.py", line 2430, in AddOp
  self._AddOpInternal(op)
File "...../tensorflow/python/ops/control_flow_ops.py", line 2458, in _AddOpInternal
  self._MaybeAddControlDependency(op)
File "...../tensorflow/python/ops/control_flow_ops.py", line 2496, in _MaybeAddControlDependency
  op._add_control_input(self.GetControlPivot().op)

更高级别的堆栈跟踪还有更多,但这似乎更相关。在Ipython调试器上,我获得以下附加信息

ipdb> self
<tensorflow.python.ops.control_flow_ops.WhileContext object at 0x7fa4d32bf7b8>
ipdb> self.name
'gradients/RelnetBabi/map/while/RelnetBabi/StoryEmbedding/rnn/while/while_context'
ipdb> op
<tf.Operation 'gradients/b_count_13/Identity' type=Identity>

上面self.name中的'rnn'是tf.nn.dynamic_rnn的一个实例。看来动态rnn创建的while循环上下文没有“枢轴”。对这里可能存在的问题有任何想法吗?

我正在使用Python 3.5和tensorflow 1.9.0

0 个答案:

没有答案