Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b5986c84
提交
b5986c84
authored
12月 20, 2010
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make code more clear following code review: changed some variable name and use named argument.
上级
8f047057
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
25 行增加
和
19 行删除
+25
-19
test_basic_ops.py
theano/sandbox/cuda/tests/test_basic_ops.py
+1
-1
test_basic.py
theano/sparse/tests/test_basic.py
+11
-5
test_sharedvar.py
theano/tensor/tests/test_sharedvar.py
+13
-13
没有找到文件。
theano/sandbox/cuda/tests/test_basic_ops.py
浏览文件 @
b5986c84
...
@@ -832,7 +832,7 @@ test_shared_options = theano.tensor.tests.test_sharedvar.makeSharedTester(
...
@@ -832,7 +832,7 @@ test_shared_options = theano.tensor.tests.test_sharedvar.makeSharedTester(
theano_fct_
=
theano
.
tensor
.
exp
,
theano_fct_
=
theano
.
tensor
.
exp
,
ref_fct_
=
numpy
.
exp
,
ref_fct_
=
numpy
.
exp
,
cast_value_
=
numpy
.
asarray
,
cast_value_
=
numpy
.
asarray
,
add
_matrix_
=
True
)
op_by
_matrix_
=
True
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test_many_arg_elemwise
()
test_many_arg_elemwise
()
...
...
theano/sparse/tests/test_basic.py
浏览文件 @
b5986c84
...
@@ -501,11 +501,17 @@ def test_may_share_memory():
...
@@ -501,11 +501,17 @@ def test_may_share_memory():
import
theano.tensor.tests.test_sharedvar
import
theano.tensor.tests.test_sharedvar
test_shared_options
=
theano
.
tensor
.
tests
.
test_sharedvar
.
makeSharedTester
(
test_shared_options
=
theano
.
tensor
.
tests
.
test_sharedvar
.
makeSharedTester
(
theano
.
sparse
.
shared
,
'float64'
,
shared_constructor_
=
theano
.
sparse
.
shared
,
True
,
True
,
True
,
scipy
.
sparse
.
csc_matrix
,
scipy
.
sparse
.
issparse
,
dtype_
=
'float64'
,
lambda
a
:
dense_from_sparse
(
a
*
2.
),
get_value_borrow_true_alias_
=
True
,
lambda
a
:
numpy
.
asarray
((
a
*
2
)
.
todense
()),
shared_borrow_true_alias_
=
True
,
scipy
.
sparse
.
csr_matrix
)
set_value_borrow_true_alias_
=
True
,
internal_type_
=
scipy
.
sparse
.
csc_matrix
,
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
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
theano/tensor/tests/test_sharedvar.py
浏览文件 @
b5986c84
...
@@ -17,7 +17,7 @@ def makeSharedTester(shared_constructor_,
...
@@ -17,7 +17,7 @@ def makeSharedTester(shared_constructor_,
theano_fct_
,
theano_fct_
,
ref_fct_
,
ref_fct_
,
cast_value_
=
numpy
.
asarray
,
cast_value_
=
numpy
.
asarray
,
add
_matrix_
=
False
):
op_by
_matrix_
=
False
):
"""
"""
This is a generic fct to allow reusing the same test function
This is a generic fct to allow reusing the same test function
for many shared variable of many types.
for many shared variable of many types.
...
@@ -35,7 +35,7 @@ def makeSharedTester(shared_constructor_,
...
@@ -35,7 +35,7 @@ def makeSharedTester(shared_constructor_,
ref_fct
=
staticmethod
(
ref_fct_
)
ref_fct
=
staticmethod
(
ref_fct_
)
set_value_borrow_true_alias
=
set_value_borrow_true_alias_
set_value_borrow_true_alias
=
set_value_borrow_true_alias_
cast_value
=
staticmethod
(
cast_value_
)
cast_value
=
staticmethod
(
cast_value_
)
add_matrix
=
add
_matrix_
op_by_matrix
=
op_by
_matrix_
def
test_shared_dont_alias
(
self
):
def
test_shared_dont_alias
(
self
):
dtype
=
self
.
dtype
dtype
=
self
.
dtype
...
@@ -146,12 +146,12 @@ def makeSharedTester(shared_constructor_,
...
@@ -146,12 +146,12 @@ def makeSharedTester(shared_constructor_,
x
=
x_shared
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)
x
=
x_shared
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)
assert
self
.
test_internal_type
(
x
)
assert
self
.
test_internal_type
(
x
)
values_to_
add
=
.
5
values_to_
div
=
.
5
if
self
.
add
_matrix
:
if
self
.
op_by
_matrix
:
#supported for cudandarray, but not ndarray.
#supported for cudandarray, but not ndarray.
values_to_
add
=
self
.
internal_type
(
values_to_
div
=
self
.
internal_type
(
numpy
.
ones
(
x
.
shape
,
dtype
=
dtype
)
/
2
)
numpy
.
ones
(
x
.
shape
,
dtype
=
dtype
)
/
2
)
x
/=
values_to_
add
#supported by ndarray and CudaNdarray
x
/=
values_to_
div
#supported by ndarray and CudaNdarray
#this is not required by the contract but it is a feature we can
#this is not required by the contract but it is a feature we can
#implement for some type of SharedVariable.
#implement for some type of SharedVariable.
...
@@ -160,7 +160,7 @@ def makeSharedTester(shared_constructor_,
...
@@ -160,7 +160,7 @@ def makeSharedTester(shared_constructor_,
x
=
x_shared
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
x
=
x_shared
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
assert
self
.
test_internal_type
(
x
)
assert
self
.
test_internal_type
(
x
)
assert
x
is
not
x_shared
.
container
.
value
assert
x
is
not
x_shared
.
container
.
value
x
/=
values_to_
add
#supported by ndarray and CudaNdarray
x
/=
values_to_
div
#supported by ndarray and CudaNdarray
#this is required by the contract
#this is required by the contract
assert
not
numpy
.
allclose
(
self
.
ref_fct
(
x
),
total_func
())
assert
not
numpy
.
allclose
(
self
.
ref_fct
(
x
),
total_func
())
...
@@ -198,12 +198,12 @@ def makeSharedTester(shared_constructor_,
...
@@ -198,12 +198,12 @@ def makeSharedTester(shared_constructor_,
get_x
=
x_shared
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)
get_x
=
x_shared
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)
assert
get_x
is
not
x_orig
#borrow=False to shared_constructor
assert
get_x
is
not
x_orig
#borrow=False to shared_constructor
assert
self
.
test_internal_type
(
get_x
)
assert
self
.
test_internal_type
(
get_x
)
values_to_
add
=
.
5
values_to_
div
=
.
5
if
self
.
add
_matrix
:
if
self
.
op_by
_matrix
:
values_to_
add
=
self
.
internal_type
(
numpy
.
ones
(
x
.
shape
,
dtype
=
dtype
)
/
2
)
#supported for cudandarray, but not ndarray.
values_to_
div
=
self
.
internal_type
(
numpy
.
ones
(
x
.
shape
,
dtype
=
dtype
)
/
2
)
#supported for cudandarray, but not ndarray.
assert
self
.
test_internal_type
(
values_to_
add
)
assert
self
.
test_internal_type
(
values_to_
div
)
get_x
/=
values_to_
add
#supported by ndarray and CudaNdarray
get_x
/=
values_to_
div
#supported by ndarray and CudaNdarray
assert
self
.
test_internal_type
(
get_x
)
assert
self
.
test_internal_type
(
get_x
)
x_shared
.
set_value
(
get_x
,
borrow
=
True
)
x_shared
.
set_value
(
get_x
,
borrow
=
True
)
x
=
x_shared
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)
x
=
x_shared
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)
...
@@ -420,4 +420,4 @@ test_shared_options=makeSharedTester(
...
@@ -420,4 +420,4 @@ test_shared_options=makeSharedTester(
theano_fct_
=
theano
.
tensor
.
sum
,
theano_fct_
=
theano
.
tensor
.
sum
,
ref_fct_
=
numpy
.
sum
,
ref_fct_
=
numpy
.
sum
,
cast_value_
=
numpy
.
asarray
,
cast_value_
=
numpy
.
asarray
,
add
_matrix_
=
False
)
op_by
_matrix_
=
False
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论