Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7f6b283f
提交
7f6b283f
authored
8月 29, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix hierarchi in doc. Otherwise, the **title** was not in the TOC.
上级
641477a7
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
26 行增加
和
21 行删除
+26
-21
extending_theano.txt
doc/tutorial/extending_theano.txt
+26
-21
没有找到文件。
doc/tutorial/extending_theano.txt
浏览文件 @
7f6b283f
.. _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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论