Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
800d869c
提交
800d869c
authored
11月 04, 2011
作者:
nouiz
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #8 from delallea/nouiz-doc_str
A few small fixes
上级
3ce74063
fc23d857
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
18 行增加
和
16 行删除
+18
-16
extending_theano.txt
doc/cifarSC2011/extending_theano.txt
+11
-9
faq.txt
doc/tutorial/faq.txt
+7
-7
没有找到文件。
doc/cifarSC2011/extending_theano.txt
浏览文件 @
800d869c
...
@@ -131,29 +131,28 @@ Op example
...
@@ -131,29 +131,28 @@ Op example
return i0_shapes
return i0_shapes
def grad(self, inputs, output_grads):
def grad(self, inputs, output_grads):
return [output_grads[0]
*
2]
return [output_grads[0]
*
2]
Test it!
Test it!
.. code-block:: python
.. code-block:: python
x = theano.tensor.matrix()
x = theano.tensor.matrix()
f = theano.function([x],DoubleOp()(x))
f = theano.function([x],
DoubleOp()(x))
import numpy
import numpy
inp = numpy.random.rand(5,5)
inp = numpy.random.rand(5,
5)
out = f(inp)
out = f(inp)
assert numpy.allclose(inp
*
2, out)
assert numpy.allclose(inp
*
2, out)
print inp
print inp
print out
print out
Testing the gradient
Testing the gradient
--------------------
--------------------
The function :ref:`verify_grad
The function :ref:`verify_grad <validating_grad>`
<validating_grad>`
verifies the gradient of an Op or Theano graph. It compares the
verify the gradient of an Op or Theano graph. It compare the
analytic (symbolically computed) gradient and the numeric
analytic(symbolicaly computed) gradient and the numeric
gradient (computed through the Finite Difference Method).
gradient(computed through the Finite Difference Method).
To verify the grad method of the DoubleOp, you can use this:
To verify the grad method of the DoubleOp, you can use this:
...
@@ -163,6 +162,9 @@ To verify the grad method of the DoubleOp, you can use this:
...
@@ -163,6 +162,9 @@ To verify the grad method of the DoubleOp, you can use this:
import theano.tests
import theano.tests
theano.tests.unittest_tools.verify_grad(DoubleOp(), [numpy.random.rand(5,7,2)])
theano.tests.unittest_tools.verify_grad(DoubleOp(), [numpy.random.rand(5,7,2)])
If nothing happens, then it works! If you want to see it fail, you can
implement a wrong gradient (for instance removing the multiplication by 2).
Exercises 8
Exercises 8
-----------
-----------
...
...
doc/tutorial/faq.txt
浏览文件 @
800d869c
...
@@ -6,7 +6,7 @@ Frequently Asked Questions
...
@@ -6,7 +6,7 @@ Frequently Asked Questions
==========================
==========================
TypeError: object of type 'TensorVariable' has no len()
TypeError: object of type 'TensorVariable' has no len()
-------------------------------------------------------
-------
-------------------------------------------------------
If you receive this error:
If you receive this error:
...
@@ -14,10 +14,10 @@ If you receive this error:
...
@@ -14,10 +14,10 @@ If you receive this error:
TypeError: object of type 'TensorVariable' has no len()
TypeError: object of type 'TensorVariable' has no len()
We can't implement the __len__ function on Theano Vari
ble
. This is
We can't implement the __len__ function on Theano Vari
ables
. This is
because Python requ
est that we return an integer, but we can't do this
because Python requ
ires that this function returns an integer, but we
as we are working with symbolic variable. You can use `var.shape[0]`
can't do this as we are working with symbolic variables. You can use
as a workaround.
`var.shape[0]`
as a workaround.
Also we can't change the
error to a better one for some other Python
Also we can't change the
above error message into a more explicit one
internal behavior that we can't change
.
because of some other Python internal behavior that can't be modified
.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论