调试CRF出现的错误:cannot be interpreted as a Tensor.

CRF参考代码:https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/crf

利用tensorflow调试CRF代码出现如下错误:

ValueError: Fetch argument  cannot be interpreted as a Tensor. (Tensor Tensor("ReverseSequence_1:0", shape=(10, 20), dtype=int32) is not an element of this graph.)
参考解决方法:

https://stackoverflow.com/questions/44299638/fetch-argument-tf-tensor-batch0-shape-128-56-56-3-dtype-float32-cannot

使用tensorflow.constant创建常量,例如:

a = tf.constant(2, tf.int16)
b = tf.constant(4, tf.float32)
接下来在使用张量a、b时候就会出现如上的错误。

这是因为使用常量时候,再使用:

with tf.Graph().as_default():
会导致两次创建的图不一致。导致出现上述错误。

把代码中这就话注释掉即可。

你可能感兴趣的:(深度学习相关)