Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e49b58aa
提交
e49b58aa
authored
3月 01, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update comment and add doc about the new warning in the infer_shape tester.
上级
bf645558
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
32 行增加
和
7 行删除
+32
-7
extending_theano.txt
doc/tutorial/extending_theano.txt
+12
-2
unittest_tools.py
theano/tests/unittest_tools.py
+20
-5
没有找到文件。
doc/tutorial/extending_theano.txt
浏览文件 @
e49b58aa
...
@@ -228,13 +228,23 @@ output.
...
@@ -228,13 +228,23 @@ output.
``self._compile_and_check`` compiles a Theano function. It takes as
``self._compile_and_check`` compiles a Theano function. It takes as
parameters the lists of input and output Theano variables, as would be
parameters the lists of input and output Theano variables, as would be
provided to ``theano.function``, and a list of real values to pass to the
provided to ``theano.function``, and a list of real values to pass to the
compiled function (do not use symmetric shapes, e.g. (3, 3),
compiled function. It also takes the op class as a parameter
as they can easily hide errors). It also takes the op class as a parameter
in order to verify that no instance of it appears in the shape-optimized graph.
in order to verify that no instance of it appears in the shape-optimized graph.
If there is an error, the function raises an exception. If you want to
If there is an error, the function raises an exception. If you want to
see it fail, you can implement an incorrect ``infer_shape``.
see it fail, you can implement an incorrect ``infer_shape``.
When testing with input values with shapes that take the same value
over different dimensions (for instance, a square matrix, or a tensor3
with shape (n, n, n), or (m, n, m)), it is not possible to detect if
the output shape was computed correctly, or if some shapes with the
same value have been mixed up. For instance, if the infer_shape uses
the width of a matrix instead of its height, then testing with only
square matrices will not detect the problem. This is why the
``self._compile_and_check`` method print a warning in such a case. If
your op work only in such case, you can diable the warning with the
warn=True parameter.
.. code-block:: python
.. code-block:: python
from theano.tests import unittest_tools as utt
from theano.tests import unittest_tools as utt
...
...
theano/tests/unittest_tools.py
浏览文件 @
e49b58aa
...
@@ -176,7 +176,19 @@ class InferShapeTester(unittest.TestCase):
...
@@ -176,7 +176,19 @@ class InferShapeTester(unittest.TestCase):
def
_compile_and_check
(
self
,
inputs
,
outputs
,
numeric_inputs
,
cls
,
def
_compile_and_check
(
self
,
inputs
,
outputs
,
numeric_inputs
,
cls
,
excluding
=
None
,
warn
=
True
):
excluding
=
None
,
warn
=
True
):
"""This tests the infer_shape method only"""
"""This tests the infer_shape method only
When testing with input values with shapes that take the same
value over different dimensions (for instance, a square
matrix, or a tensor3 with shape (n, n, n), or (m, n, m)), it
is not possible to detect if the output shape was computed
correctly, or if some shapes with the same value have been
mixed up. For instance, if the infer_shape uses the width of a
matrix instead of its height, then testing with only square
matrices will not detect the problem. If warn=True, we emit a
warning when testing with such values.
"""
mode
=
self
.
mode
mode
=
self
.
mode
if
excluding
:
if
excluding
:
mode
=
mode
.
excluding
(
*
excluding
)
mode
=
mode
.
excluding
(
*
excluding
)
...
@@ -194,10 +206,13 @@ class InferShapeTester(unittest.TestCase):
...
@@ -194,10 +206,13 @@ class InferShapeTester(unittest.TestCase):
else
:
else
:
shp
=
inp
.
shape
shp
=
inp
.
shape
if
len
(
set
(
shp
))
!=
len
(
shp
):
if
len
(
set
(
shp
))
!=
len
(
shp
):
_logger
.
warn
(
"While testing the shape, we received input"
_logger
.
warn
(
" with dimensions of the same shape
%
s! This"
"While testing the shape inference, we received an"
" lower the quality of the verification."
,
" input with a shape that has some repeated values:
%
s"
str
(
inp
.
shape
))
", like a square matrix. This makes it impossible to"
" check if the values for these dimensions have been"
" correctly used, or if they have been mixed up."
,
str
(
inp
.
shape
))
break
break
outputs_function
=
theano
.
function
(
inputs
,
outputs
,
mode
=
mode
)
outputs_function
=
theano
.
function
(
inputs
,
outputs
,
mode
=
mode
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论