Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tensorflow tf.contrib.seq2seq.gather_树如何工作?_Tensorflow_Beam Search - Fatal编程技术网

Tensorflow tf.contrib.seq2seq.gather_树如何工作?

Tensorflow tf.contrib.seq2seq.gather_树如何工作?,tensorflow,beam-search,Tensorflow,Beam Search,contrib.seq2seq中的collect_树是如何工作的?我可以看到它接受预测的ID和光束父ID,并以某种方式返回最终的光束,但是引擎盖下面到底发生了什么?似乎没有任何Python代码库可以让我检查出来。答案不是很清楚 tf.contrib.seq2seq.gather\u tree是否有任何代码源?我正在使用TensorFlow 1.3并查看内部gen\u beam\u search\u ops.py似乎没有帮助。代码详细如下: def-gather_-tree_-py(值、父项):

contrib.seq2seq
中的
collect_树
是如何工作的?我可以看到它接受预测的ID和光束父ID,并以某种方式返回最终的光束,但是引擎盖下面到底发生了什么?似乎没有任何Python代码库可以让我检查出来。答案不是很清楚


tf.contrib.seq2seq.gather\u tree
是否有任何代码源?我正在使用TensorFlow 1.3并查看内部
gen\u beam\u search\u ops.py
似乎没有帮助。

代码详细如下:

def-gather_-tree_-py(值、父项):
“”“从左节点向后收集通过树的路径。已使用
重建给他们父母的梁
梁长度=值。形状[0]
num_beams=值。形状[1]
res=np.类零(值)
res[-1,:]=值[-1,:]
对于范围内的波束id(波束数):
父项=父项[-1][beam\u id]
对于反向电平(范围(光束长度-1)):
res[level,beam_id]=值[level][parent]
家长=家长[级别][家长]
返回np.array(res.astype)(values.dtype)
def聚集树(值、父级):
“”“聚集树的张量版本”“”
res=tf.py_func(
func=gather\u tree\u py,inp=[values,parents],Tout=values.dtype)
res.set_shape(value.get_shape().as_list())
返回res