tf.contrib.crf.crf_decode
- 当句子的序列长度大于指定的句子有效长度时,也就是sequence_length
o = [[[0.1,0.4,0.5],[0.5,0.4,0.1],[0.4,0.5,0.1]],[[0.1,0.2,0.7],[0.4,0.5,0.1],[0.4,0.5,0.1]]]
a = [[0.1,0.5,0.4],[0.7,0.1,0.2],[0.5,0.3,0.2]]
a = tf.convert_to_tensor(a)
o = tf.convert_to_tensor(o)
p,s = tf.contrib.crf.crf_decode(o,a, tf.convert_to_tensor([2],tf.int32))
p1,s = tf.contrib.crf.crf_decode(o,a, tf.convert_to_tensor([3],tf.int32))
with tf.Session() as sess:
print(sess.run(p,p1))
结果
[[1 0 0 0 0 0]]
[[1 0 1 0 0 0]]