在tensorflow中,tf.nn.static_rnn和和有什么区别tf.nn.dynamic_rnn?何时使用它们?
两者都采用sequence_length使计算适应输入的实际长度的参数。好像static_rnn不限于固定大小的输入,对吗?
dynamic_rnn 具有以下额外参数:
parallel_iterationsswap_memorytime_major但是我想这些只是微小的差异。
所以之间的主要区别是什么tf.nn.static_rnn和tf.nn.dynamic_rnn我们何时应该使用一个比其他?
Jus*_*lli 10
这仍然是一个有用的资源(尽管是几年前编写的):http : //www.wildml.com/2016/08/rnns-in-tensorflow-a-practical-guide-and-undocumented-features/
在其中,Denny Britz对静态/动态问题有以下评论:
静态的
在内部,
tf.nn.rnn为固定的RNN长度创建展开图。这意味着,如果tf.nn.rnn使用具有200个时间步长的输入进行调用,则将创建具有200个RNN步骤的静态图形。首先,图形创建很慢。其次,您无法传递比原来指定的更长的序列(> 200)。
动态
tf.nn.dynamic_rnnsolves this. It uses atf.Whileloop to dynamically construct the graph when it is executed. That means graph creation is faster and you can feed batches of variable size.
In general he concludes that there is no real benefit in using tf.nn.static_rnn and that for most cases you'll want to resort to tf.nn.dynamic_rnn
For what it's worth, I've had the same experience myself.
| 归档时间: |
|
| 查看次数: |
3228 次 |
| 最近记录: |