Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
33530514
提交
33530514
authored
7月 04, 2011
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed some test names so that names reported by nosetests can be used to re-run tests.
This is needed e.g. for the --with-id option of nosetests to work properly.
上级
4b570d40
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
39 行增加
和
11 行删除
+39
-11
test_basic_ops.py
theano/sandbox/cuda/tests/test_basic_ops.py
+4
-2
test_basic.py
theano/sparse/tests/test_basic.py
+3
-1
test_basic.py
theano/tensor/tests/test_basic.py
+19
-4
test_sharedvar.py
theano/tensor/tests/test_sharedvar.py
+13
-4
没有找到文件。
theano/sandbox/cuda/tests/test_basic_ops.py
浏览文件 @
33530514
...
...
@@ -920,7 +920,8 @@ test_shared_options = theano.tensor.tests.test_sharedvar.makeSharedTester(
theano_fct_
=
theano
.
tensor
.
exp
,
ref_fct_
=
numpy
.
exp
,
cast_value_
=
cuda
.
as_cuda_array
,
op_by_matrix_
=
True
)
op_by_matrix_
=
True
,
name
=
'test_shared_options'
)
#This test the case when the shared constructor view an ndarray as input
test_shared_options2
=
theano
.
tensor
.
tests
.
test_sharedvar
.
makeSharedTester
(
...
...
@@ -937,7 +938,8 @@ test_shared_options2 = theano.tensor.tests.test_sharedvar.makeSharedTester(
theano_fct_
=
theano
.
tensor
.
exp
,
ref_fct_
=
numpy
.
exp
,
cast_value_
=
numpy
.
asarray
,
op_by_matrix_
=
True
)
op_by_matrix_
=
True
,
name
=
'test_shared_options'
)
if
__name__
==
'__main__'
:
test_many_arg_elemwise
()
...
...
theano/sparse/tests/test_basic.py
浏览文件 @
33530514
...
...
@@ -584,7 +584,9 @@ test_shared_options=theano.tensor.tests.test_sharedvar.makeSharedTester(
test_internal_type_
=
scipy
.
sparse
.
issparse
,
theano_fct_
=
lambda
a
:
dense_from_sparse
(
a
*
2.
),
ref_fct_
=
lambda
a
:
numpy
.
asarray
((
a
*
2
)
.
todense
()),
cast_value_
=
scipy
.
sparse
.
csr_matrix
)
cast_value_
=
scipy
.
sparse
.
csr_matrix
,
name
=
'test_shared_options'
,
)
if
__name__
==
'__main__'
:
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
33530514
...
...
@@ -304,8 +304,23 @@ def rand_of_dtype(shape, dtype):
else
:
raise
TypeError
()
def
makeBroadcastTester
(
op
,
expected
,
checks
=
{},
**
kwargs
):
name
=
str
(
op
)
+
"Tester"
def
makeBroadcastTester
(
op
,
expected
,
checks
=
{},
name
=
None
,
**
kwargs
):
name
=
str
(
op
)
# Here we ensure the test name matches the name of the variable defined in
# this script. This is needed to properly identify the test e.g. with the
# --with-id option of nosetests, or simply to rerun a specific test that
# failed.
capitalize
=
False
if
name
.
startswith
(
'Elemwise{'
)
and
name
.
endswith
(
',no_inplace}'
):
# For instance: Elemwise{add,no_inplace} -> Add
name
=
name
[
9
:
-
12
]
capitalize
=
True
elif
name
.
endswith
(
'_inplace'
):
# For instance: sub_inplace -> SubInplace
capitalize
=
True
if
capitalize
:
name
=
''
.
join
([
x
.
capitalize
()
for
x
in
name
.
split
(
'_'
)])
name
+=
"Tester"
if
kwargs
.
has_key
(
'inplace'
):
if
kwargs
[
'inplace'
]:
_expected
=
expected
...
...
@@ -504,7 +519,7 @@ if config.floatX=='float32':
# float32.
# This is probably caused by our way of computing the gradient error.
div_grad_rtol
=
0.025
DivTester
=
makeBroadcastTester
(
op
=
true_div
,
True
DivTester
=
makeBroadcastTester
(
op
=
true_div
,
expected
=
lambda
x
,
y
:
check_floatX
((
x
,
y
),
x
/
y
),
good
=
_good_broadcast_div_mod_normal_float
,
# integers = (randint(2, 3), randint_nonzero(2, 3)),
...
...
@@ -513,7 +528,7 @@ DivTester = makeBroadcastTester(op = true_div,
grad
=
_grad_broadcast_div_mod_normal
,
grad_rtol
=
div_grad_rtol
,
)
DivInplaceTester
=
makeBroadcastTester
(
op
=
inplace
.
true_div_inplace
,
True
DivInplaceTester
=
makeBroadcastTester
(
op
=
inplace
.
true_div_inplace
,
expected
=
lambda
x
,
y
:
x
/
y
,
good
=
_good_broadcast_div_mod_normal_float_inplace
,
grad
=
_grad_broadcast_div_mod_normal
,
...
...
theano/tensor/tests/test_sharedvar.py
浏览文件 @
33530514
...
...
@@ -23,7 +23,9 @@ def makeSharedTester(shared_constructor_,
theano_fct_
,
ref_fct_
,
cast_value_
=
numpy
.
asarray
,
op_by_matrix_
=
False
):
op_by_matrix_
=
False
,
name
=
None
,
):
"""
This is a generic fct to allow reusing the same test function
for many shared variable of many types.
...
...
@@ -46,7 +48,12 @@ def makeSharedTester(shared_constructor_,
:param ref_fct_: A reference function that should return the same value as the theano_fct_
:param cast_value_: A callable that cast an ndarray into the internal shared variable representation
:param op_by_matrix_: When we do inplace operation on the an internal type object, should we do it with a scalar or a matrix of the same value.
:param name: This string is used to set the returned class' __name__
attribute. This is needed for nosetests to properly tag the
test with its correct name, rather than use the generic
SharedTester name. This parameter is mandatory (keeping the
default None value will raise an error), and must be set to
the name of the variable that will hold the returned class.
:note:
We must use /= as sparse type don't support other inplace operation.
...
...
@@ -607,7 +614,8 @@ def makeSharedTester(shared_constructor_,
assert
not
x_shared
.
type
.
values_eq
(
x
,
y
)
assert
not
x_shared
.
type
.
values_eq_approx
(
x
,
y
)
assert
name
is
not
None
SharedTester
.
__name__
=
name
return
SharedTester
...
...
@@ -625,4 +633,5 @@ test_shared_options=makeSharedTester(
theano_fct_
=
lambda
a
:
a
*
2
,
ref_fct_
=
lambda
a
:
numpy
.
asarray
((
a
*
2
)),
cast_value_
=
numpy
.
asarray
,
op_by_matrix_
=
False
)
op_by_matrix_
=
False
,
name
=
'test_shared_options'
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论