Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
42f1bf62
提交
42f1bf62
authored
2月 03, 2009
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added some pickling tests of module
上级
f5ec9504
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
59 行增加
和
1 行删除
+59
-1
test_module.py
theano/compile/tests/test_module.py
+59
-1
没有找到文件。
theano/compile/tests/test_module.py
浏览文件 @
42f1bf62
#!/usr/bin/env python
import
unittest
import
cPickle
,
numpy
,
unittest
from
theano.compile.module
import
*
import
theano.tensor
as
T
import
sys
...
...
@@ -352,6 +352,64 @@ class T_test_module(unittest.TestCase):
As Result with more optimization?"""
print
>>
sys
.
stderr
,
"WARNING MODULE TEST NOT IMPLEMENTED"
def
test_pickle
():
"""Test that a module can be pickled"""
M
=
Module
()
M
.
x
=
Member
(
T
.
dmatrix
())
M
.
y
=
Member
(
T
.
dmatrix
())
a
=
T
.
dmatrix
()
M
.
f
=
Method
([
a
],
a
+
M
.
x
+
M
.
y
)
M
.
g
=
Method
([
a
],
a
*
M
.
x
*
M
.
y
)
m
=
M
.
make
(
x
=
numpy
.
zeros
((
4
,
5
)),
y
=
numpy
.
ones
((
2
,
3
)))
m_dup
=
cPickle
.
loads
(
cPickle
.
dumps
(
m
))
assert
numpy
.
all
(
m
.
x
==
m_dup
.
x
)
and
numpy
.
all
(
m
.
y
==
m_dup
.
y
)
m_dup
.
x
[
0
,
0
]
=
3.142
assert
m_dup
.
f
.
input_storage
[
1
]
.
data
[
0
,
0
]
==
3.142
assert
m
.
x
[
0
,
0
]
==
0.0
#ensure that m is not aliased to m_dup
#check that the unpickled version has the same argument/property aliasing
assert
m_dup
.
x
is
m_dup
.
f
.
input_storage
[
1
]
.
data
assert
m_dup
.
y
is
m_dup
.
f
.
input_storage
[
2
]
.
data
assert
m_dup
.
x
is
m_dup
.
g
.
input_storage
[
1
]
.
data
assert
m_dup
.
y
is
m_dup
.
g
.
input_storage
[
2
]
.
data
def
test_pickle_aliased_memory
():
M
=
Module
()
M
.
x
=
Member
(
T
.
dmatrix
())
M
.
y
=
Member
(
T
.
dmatrix
())
a
=
T
.
dmatrix
()
M
.
f
=
Method
([
a
],
a
+
M
.
x
+
M
.
y
)
M
.
g
=
Method
([
a
],
a
*
M
.
x
*
M
.
y
)
m
=
M
.
make
(
x
=
numpy
.
zeros
((
4
,
5
)),
y
=
numpy
.
ones
((
2
,
3
)))
m
.
y
=
m
.
x
[:]
m_dup
=
cPickle
.
loads
(
cPickle
.
dumps
(
m
))
#m's memory is aliased....
m
.
x
[
0
,
0
]
=
3.14
assert
m
.
y
[
0
,
0
]
==
3.14
#is m_dup's memory aliased?
m_dup
.
x
[
0
,
0
]
=
3.14
assert
m_dup
.
y
[
0
,
0
]
==
3.14
#m's memory is aliased differently....
m
.
y
=
m
.
x
[
1
:
2
]
m_dup
=
cPickle
.
loads
(
cPickle
.
dumps
(
m
))
#is m_dup's memory aliased the same way?
m
.
x
[
1
,
0
]
=
3.142
assert
m
.
y
[
0
,
0
]
==
3.142
m_dup
.
x
[
1
,
0
]
=
3.142
assert
m_dup
.
y
[
0
,
0
]
==
3.142
if
__name__
==
'__main__'
:
from
theano.tests
import
main
# main(__file__[:-3])
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论