提交 8ced660d authored 作者: Frederic's avatar Frederic

Add OpFromGraph in the doc.

上级 0bde7a3c
.. _opfromgraph:
===========
OpFromGraph
===========
This page descripbe :class:`theano.OpFromGraph
<theano.compile.builders.OpFromGraph>`. an Op that allow to
encapsulate a Theano graph in an op.
This can be used to encapsulate some functionality in one block. It is
useful to scale Theano compilation for regular bigger graph when we
reuse that encapsulated fonctionality with different inputs many
times. Due to this encapsulation, it can make Theano compilation phase
faster for graph with many nodes.
Using this for small graph isn't recommanded as it disable
optimization between what is inside the encapsulation and outside it.
.. note:
This wasn't used widely up to now. If you have any
questions/comments don't contact us on the mailing list.
.. autoclass:: theano.compile.builders.OpFromGraph
import theano
from theano import tensor, OpFromGraph
x, y, z = tensor.vectors("xyz")
out1 = x + y
out2 = x + z
new_op = OpFromGraph([x, y, z], [out1, out2])
# This apply new_op to x, y and z. outs is a list of output variable.
outs = new_op(x, y, z)
f1 = theano.function([x, y, z], [out1, out2])
f2 = theano.function([x, y, z], outs)
print "Normal graph"
theano.printing.debugprint(f1)
print "Encapsulated graph"
theano.printing.debugprint(f2)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论