使用Tensorflow或Theano的循环计算图 [英] Cyclic computational graphs with Tensorflow or Theano

查看:144
本文介绍了使用Tensorflow或Theano的循环计算图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TensorFlowTheano似乎都不支持循环计算图,循环元素被实现为具有缓冲和展开功能的循环单元(RNN/LSTM单元),但是此限制主要与反向计算有关.传播.我对计算反向传播并没有特别的需求,而仅对正向传播进行计算.

Both TensorFlow and Theano do not seem to support cyclic computational graphs, cyclic elements are implemented as recurrent cells with buffer and unrolling (RNN / LSTM cells), but this limitation is mostly related with the computation of back-propagation. I don't have a particular need for computing back-propagation but just the forward propagations.

有没有办法忽略此限制,或者只是打破非循环成分中的任意计算图?

Is there a way to ignore this limitation, or perhaps just to break down arbitrary computational graphs in acyclic components?

推荐答案

TensorFlow 支持. tf.while_loop() 函数允许您指定一个带有任意子图的while循环,用于循环的条件和主体,运行时将并行执行循环. tf.scan() 函数是更高版本的-级别的API,类似于Theano的 theano.scan() 函数.两者都允许您遍历动态大小的张量.

TensorFlow does support cyclic computation graphs. The tf.while_loop() function allows you to specify a while loop with arbitrary subgraphs for the condition and the body of the loop, and the runtime will execute the loop in parallel. The tf.scan() function is a higher-level API that is similar to Theano's theano.scan() function. Both allow you to loop over tensors of dynamic size.

这篇关于使用Tensorflow或Theano的循环计算图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆