提交 7f6b283f authored 作者: Frederic's avatar Frederic

Fix hierarchi in doc. Otherwise, the **title** was not in the TOC.

上级 641477a7
.. _extending_theano:
****************
================
Extending Theano
****************
================
Theano Graphs
-------------
=============
- Theano works with symbolic graphs.
- Those graphs are bi-partite graphs (graph with 2 types of nodes).
......@@ -43,7 +43,7 @@ Inputs and Outputs are lists of Theano variables.
Op Contract
-----------
===========
.. code-block:: python
......@@ -126,7 +126,7 @@ The :func:`R_op` method is needed if you want ``theano.tensor.Rop`` to
work with your op.
Op Example
----------
==========
.. code-block:: python
......@@ -181,13 +181,14 @@ You can try it as follows:
How To Test it
--------------
==============
Theano has some functionalities to simplify testing. These help test the
``infer_shape``, ``grad`` and ``R_op`` methods. Put the following code
in a file and execute it with the ``theano-nose`` program.
**Basic Tests**
Basic Tests
-----------
Basic tests are done by you just by using the op and checking that it
returns the right answer. If you detect an error, you must raise an
......@@ -212,7 +213,9 @@ returns the right answer. If you detect an error, you must raise an
# Compare the result computed to the expected value.
assert numpy.allclose(inp * 2, out)
**Testing the infer_shape**
Testing the infer_shape
-----------------------
When a class inherits from the ``InferShapeTester`` class, it gets the
``self._compile_and_check`` method that tests the op's ``infer_shape``
......@@ -249,7 +252,8 @@ see it fail, you can implement an incorrect ``infer_shape``.
# Op that should be removed from the graph.
self.op_class)
**Testing the gradient**
Testing the gradient
--------------------
The function :ref:`verify_grad <validating_grad>`
verifies the gradient of an op or Theano graph. It compares the
......@@ -266,7 +270,8 @@ the multiplication by 2).
theano.tests.unittest_tools.verify_grad(self.op,
[numpy.random.rand(5, 7, 2)])
**Testing the Rop**
Testing the Rop
---------------
.. TODO: repair defective links in the following paragraph
......@@ -289,8 +294,8 @@ For instance, to verify the Rop method of the DoubleOp, you can use this:
self.check_rop_lop(DoubleRop()(self.x), self.in_shape)
**Testing GPU Ops**
Testing GPU Ops
---------------
Ops to be executed on the GPU should inherit from the ``theano.sandbox.cuda.GpuOp``
and not ``theano.Op``. This allows Theano to distinguish them. Currently, we
......@@ -327,7 +332,8 @@ particular classes or even for particular tests:
Help with the use and functionalities of ``theano-nose`` may be obtained by running
it with the command line parameter ``--help (-h)``.
**nosetests**
nosetests
---------
The command ``nosetests`` can also be used. Although it lacks the useful
functionalities that ``theano-nose`` provides, ``nosetests`` can be called similarly
......@@ -338,7 +344,8 @@ to ``theano-nose`` from any folder in Python's path like so:
More documentation on ``nosetests`` is available here:
`nosetests <http://readthedocs.org/docs/nose/en/latest/>`_.
**In-file**
In-file
-------
One may also add a block of code similar to the following at the end of the
file containing a specific test of interest and run the file. In this example, the test
......@@ -355,8 +362,9 @@ file containing a specific test of interest and run the file. In this example, t
-------------------------------------------
**Exercise**
Exercise
========
Run the code of the *DoubleOp* example above.
......@@ -414,14 +422,11 @@ don't forget to call the parent ``setUp`` function.
For more details see :ref:`random_value_in_tests`.
.. TODO: repair this link
:download:`Solution<../extending_theano_solution_1.py>`
-------------------------------------------
:download:`Solution<extending_theano_solution_1.py>`
**A Final Note:**
Final Note
==========
A more extensive discussion of this section's content may be found in the advanced
tutorial :ref:`Extending Theano<extending>`
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论