擅长:python、mysql、java
<p>目前,由于图的结构依赖于输入,这些模型很难在TensorFlow中高效、干净地实现。这也使得小批量处理变得非常困难。可以使用像您提到的while循环这样的东西,但要做到干净并不容易。在</p>
<p>你可以为每个例子建立一个新的图表,但这将是非常烦人的。如果,对于给定的输入大小,您可以枚举数量相当少的可能的图,您可以在它们之间选择并一次构建它们,但对于较大的输入,这是不可能的。在</p>
<p>您也可以通过复杂的图形来路由示例tf.聚集逻辑和面具,但这也可能是一个巨大的痛苦。在</p>
<p>最终,动态构建每个示例的图形可能是最简单的,而且将来有可能会有其他方法支持更好的即时样式执行。但从0.8版开始,我希望这会有点烦人,并且会带来一些开销,正如雅罗斯拉夫在评论中提到的那样。在</p>
<p>编辑:既然我回答了,下面是一个使用while循环的静态图的例子:<a href="https://github.com/bogatyy/cs224d/tree/master/assignment3" rel="nofollow noreferrer">https://github.com/bogatyy/cs224d/tree/master/assignment3</a>
我不知道它与这种模式的自定义C++代码相比有多大的性能,尽管原则上它可以批量化。在</p>