Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
40274190
提交
40274190
authored
6月 07, 2011
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Put back the initial value of compute_test_value at the end of tests
上级
6f2690dd
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
90 行增加
和
66 行删除
+90
-66
test_compute_test_value.py
theano/gof/tests/test_compute_test_value.py
+90
-66
没有找到文件。
theano/gof/tests/test_compute_test_value.py
浏览文件 @
40274190
...
...
@@ -8,91 +8,115 @@ from theano import tensor as T
class
TestComputeTestValue
(
unittest
.
TestCase
):
def
test_variable_only
(
self
):
theano
.
config
.
compute_test_value
=
True
orig_compute_test_value
=
theano
.
config
.
compute_test_value
try
:
theano
.
config
.
compute_test_value
=
True
x
=
T
.
matrix
(
'x'
)
x
.
tag
.
test_value
=
numpy
.
random
.
rand
(
3
,
4
)
y
=
T
.
matrix
(
'y'
)
y
.
tag
.
test_value
=
numpy
.
random
.
rand
(
4
,
5
)
# should work
z
=
T
.
dot
(
x
,
y
)
x
=
T
.
matrix
(
'x'
)
x
.
tag
.
test_value
=
numpy
.
random
.
rand
(
3
,
4
)
y
=
T
.
matrix
(
'y'
)
y
.
tag
.
test_value
=
numpy
.
random
.
rand
(
4
,
5
)
# this test should fail
y
.
tag
.
test_value
=
numpy
.
random
.
rand
(
6
,
5
)
self
.
assertRaises
(
ValueError
,
T
.
dot
,
x
,
y
)
# should work
z
=
T
.
dot
(
x
,
y
)
def
test_compute_flag
(
self
):
# this test should fail
y
.
tag
.
test_value
=
numpy
.
random
.
rand
(
6
,
5
)
self
.
assertRaises
(
ValueError
,
T
.
dot
,
x
,
y
)
finally
:
theano
.
config
.
compute_test_value
=
orig_compute_test_value
x
=
T
.
matrix
(
'x'
)
y
=
T
.
matrix
(
'y'
)
y
.
tag
.
test_value
=
numpy
.
random
.
rand
(
4
,
5
)
# should skip computation of test value
theano
.
config
.
compute_test_value
=
False
z
=
T
.
dot
(
x
,
y
)
# should fail one or another when flag is set
theano
.
config
.
compute_test_value
=
'warn'
self
.
assertRaises
(
Warning
,
T
.
dot
,
x
,
y
)
theano
.
config
.
compute_test_value
=
'err'
self
.
assertRaises
(
ValueError
,
T
.
dot
,
x
,
y
)
def
test_compute_flag
(
self
):
orig_compute_test_value
=
theano
.
config
.
compute_test_value
try
:
x
=
T
.
matrix
(
'x'
)
y
=
T
.
matrix
(
'y'
)
y
.
tag
.
test_value
=
numpy
.
random
.
rand
(
4
,
5
)
# should skip computation of test value
theano
.
config
.
compute_test_value
=
False
z
=
T
.
dot
(
x
,
y
)
# should fail one or another when flag is set
theano
.
config
.
compute_test_value
=
'warn'
self
.
assertRaises
(
Warning
,
T
.
dot
,
x
,
y
)
theano
.
config
.
compute_test_value
=
'err'
self
.
assertRaises
(
ValueError
,
T
.
dot
,
x
,
y
)
finally
:
theano
.
config
.
compute_test_value
=
orig_compute_test_value
def
test_string_var
(
self
):
theano
.
config
.
compute_test_value
=
True
orig_compute_test_value
=
theano
.
config
.
compute_test_value
try
:
theano
.
config
.
compute_test_value
=
True
x
=
T
.
matrix
(
'x'
)
x
.
tag
.
test_value
=
numpy
.
random
.
rand
(
3
,
4
)
y
=
T
.
matrix
(
'y'
)
y
.
tag
.
test_value
=
numpy
.
random
.
rand
(
4
,
5
)
x
=
T
.
matrix
(
'x'
)
x
.
tag
.
test_value
=
numpy
.
random
.
rand
(
3
,
4
)
y
=
T
.
matrix
(
'y'
)
y
.
tag
.
test_value
=
numpy
.
random
.
rand
(
4
,
5
)
z
=
theano
.
shared
(
numpy
.
random
.
rand
(
5
,
6
))
z
=
theano
.
shared
(
numpy
.
random
.
rand
(
5
,
6
))
# should work
out
=
T
.
dot
(
T
.
dot
(
x
,
y
),
z
)
def
f
(
x
,
y
,
z
):
return
T
.
dot
(
T
.
dot
(
x
,
y
),
z
)
# should work
out
=
T
.
dot
(
T
.
dot
(
x
,
y
),
z
)
def
f
(
x
,
y
,
z
):
return
T
.
dot
(
T
.
dot
(
x
,
y
),
z
)
# this test should fail
z
.
set_value
(
numpy
.
random
.
rand
(
7
,
6
))
self
.
assertRaises
(
ValueError
,
f
,
x
,
y
,
z
)
# this test should fail
z
.
set_value
(
numpy
.
random
.
rand
(
7
,
6
))
self
.
assertRaises
(
ValueError
,
f
,
x
,
y
,
z
)
finally
:
theano
.
config
.
compute_test_value
=
orig_compute_test_value
def
test_shared
(
self
):
theano
.
config
.
compute_test_value
=
True
orig_compute_test_value
=
theano
.
config
.
compute_test_value
try
:
theano
.
config
.
compute_test_value
=
True
x
=
T
.
matrix
(
'x'
)
x
.
tag
.
test_value
=
numpy
.
random
.
rand
(
3
,
4
)
y
=
theano
.
shared
(
numpy
.
random
.
rand
(
4
,
6
),
'y'
)
# should work
z
=
T
.
dot
(
x
,
y
)
x
=
T
.
matrix
(
'x'
)
x
.
tag
.
test_value
=
numpy
.
random
.
rand
(
3
,
4
)
y
=
theano
.
shared
(
numpy
.
random
.
rand
(
4
,
6
),
'y'
)
# this test should fail
y
.
set_value
(
numpy
.
random
.
rand
(
5
,
6
))
self
.
assertRaises
(
ValueError
,
T
.
dot
,
x
,
y
)
# should work
z
=
T
.
dot
(
x
,
y
)
# this test should fail
y
.
set_value
(
numpy
.
random
.
rand
(
5
,
6
))
self
.
assertRaises
(
ValueError
,
T
.
dot
,
x
,
y
)
finally
:
theano
.
config
.
compute_test_value
=
orig_compute_test_value
def
test_ndarray
(
self
):
theano
.
config
.
compute_test_value
=
True
orig_compute_test_value
=
theano
.
config
.
compute_test_value
try
:
theano
.
config
.
compute_test_value
=
True
x
=
numpy
.
random
.
rand
(
2
,
3
)
y
=
theano
.
shared
(
numpy
.
random
.
rand
(
3
,
6
),
'y'
)
x
=
numpy
.
random
.
rand
(
2
,
3
)
y
=
theano
.
shared
(
numpy
.
random
.
rand
(
3
,
6
),
'y'
)
# should work
z
=
T
.
dot
(
x
,
y
)
# should work
z
=
T
.
dot
(
x
,
y
)
# this test should fail
x
=
numpy
.
random
.
rand
(
2
,
4
)
self
.
assertRaises
(
ValueError
,
T
.
dot
,
x
,
y
)
# this test should fail
x
=
numpy
.
random
.
rand
(
2
,
4
)
self
.
assertRaises
(
ValueError
,
T
.
dot
,
x
,
y
)
finally
:
theano
.
config
.
compute_test_value
=
orig_compute_test_value
def
test_constant
(
self
):
theano
.
config
.
compute_test_value
=
True
orig_compute_test_value
=
theano
.
config
.
compute_test_value
try
:
theano
.
config
.
compute_test_value
=
True
x
=
T
.
constant
(
numpy
.
random
.
rand
(
2
,
3
))
y
=
theano
.
shared
(
numpy
.
random
.
rand
(
3
,
6
),
'y'
)
x
=
T
.
constant
(
numpy
.
random
.
rand
(
2
,
3
))
y
=
theano
.
shared
(
numpy
.
random
.
rand
(
3
,
6
),
'y'
)
# should work
z
=
T
.
dot
(
x
,
y
)
# should work
z
=
T
.
dot
(
x
,
y
)
# this test should fail
x
=
T
.
constant
(
numpy
.
random
.
rand
(
2
,
4
))
self
.
assertRaises
(
ValueError
,
T
.
dot
,
x
,
y
)
# this test should fail
x
=
T
.
constant
(
numpy
.
random
.
rand
(
2
,
4
))
self
.
assertRaises
(
ValueError
,
T
.
dot
,
x
,
y
)
finally
:
theano
.
config
.
compute_test_value
=
orig_compute_test_value
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论