提交 da82bf80 authored 作者: Joseph Turian's avatar Joseph Turian

Added doc/extending.txt

上级 4aa1cd31
================
Extending theano
================
This page introduces some important terminology for describing how theano
works. Below there is a list of HOWTO documents for extending theano.
Lets start by looking at what happens in a simple theano program.
.. code-block:: python
#!python
x = tensor.matrix('x')
y = tensor.matrix('y')
z = x + y
f = theano.function(input=[x,y], output=z, mode='FAST_RUN')
print f(numpy.ones(2,3), numpy.ones(2,3))
The first three lines build a graph_ whose nodes correspond to variables (``x,y,z``) and expressions (just the '+' here).
The variables in such a graph are Result_ instances of some Type_, and the expressions are Apply_ instances of some Op_.
The line ``f = theano.function([x,y], [z], mode='FAST_RUN')`` compiles_
the graph we built and returns a function_ whose ``__call__`` method
takes as arguments the values to use for ``x`` and ``y``.
The mode_ controls which transformations_ are applied to the graph as we compile it.
The line ``print f(numpy.ones(2,3), numpy.ones(2,3))`` creates two
matrices, and then uses f's ``__call__`` method to run the compiled
function on those inputs.
The compiled function is executed by a linker_, which was also specified by the mode_ argument to ``function``.
The instance f's ``__call__`` method returns a value for ``z`` (given ``x,y``) which we print.
Theano was designed to be extensible to new types_ of Result, new Ops_ to use in symbolic computations,
and new modes of compilation and execution. When you're comfortable with the material above, move on to:
* HowtoCreateType create a new data type,
* HowtoCreateOp create a new type of Op,
* HowtoAddTransformation add a transformation to an existing transformation mode,
* Create a new mode by HowtoCreateLinker creating a new linker, or HowtoCreateTransformationMode create a new transformation mode.
......@@ -37,7 +37,7 @@ Using Theano
.. _Howto:
.. _theano-users: http://groups.google.com/group/theano-users?pli=1
.. _theano-dev: http://groups.google.com/group/theano-dev?pli=1
.. _n00b guide: n00b.html
.. _tutorial: tutorial.html
.. _glossary of terminology: ../api/term-index.html
.. _typelist: typelist.html
.. _oplist: oplist.html
......@@ -48,6 +48,8 @@ Extending Theano
- Read about `How Theano Works <UserAdvanced.html>`__. This introduces the
major interface data structures: Op, Type, Result, Apply.
- Read about `Extending theano <extending.html>`__.
- How to make a new Op.
- How to make a new Optimization.
......
......@@ -87,7 +87,7 @@ and we are working hard to make these problems errors easier to fix.
*It would be worth thinking through the order in which these terms should be introduced.
Can we inline the text?'''*
*Note: Theano has two types of [DefineScalar scalar].*
*Note: Theano has two types of scalar_.*
Matrix example
==============
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论