Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
586ce4b9
提交
586ce4b9
authored
7月 19, 2011
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
In pickling test, work in a temporary directory that gets removed at the end.
上级
e4c6880e
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
38 行增加
和
38 行删除
+38
-38
test_tutorial.py
theano/tests/test_tutorial.py
+38
-38
没有找到文件。
theano/tests/test_tutorial.py
浏览文件 @
586ce4b9
""" test code snippet in the Theano tutorials.
"""
import
os
,
unittest
import
os
,
shutil
,
unittest
import
theano
import
theano.tensor
as
T
from
theano
import
function
...
...
@@ -705,7 +705,7 @@ class T_aliasing(unittest.TestCase):
class
T_loading_and_saving
(
unittest
.
TestCase
):
## All tests here belog to
## All tests here belo
n
g to
## http://deeplearning.net/software/theano/tutorial/loading_and_saving.html
## Theano/doc/tutorial/loading_and_saving.txt
## Any change you do here also add it to the tutorial !
...
...
@@ -722,42 +722,42 @@ class T_loading_and_saving(unittest.TestCase):
mode_instance
=
theano
.
compile
.
mode
.
get_mode
(
None
)
if
not
isinstance
(
mode_instance
,
theano
.
compile
.
debugmode
.
DebugMode
):
if
os
.
path
.
exists
(
'obj.save'
)
or
os
.
path
.
exists
(
'objects.save'
):
# We do not want to delete these files silently, in case for
# some reason they would be something else than test-generated
# files.
# Ideally we would save those files in a temporary directory...
raise
AssertionError
(
'Please get rid of files obj.save and '
'objects.save in directory
%
s'
%
os
.
getcwd
()
)
f
=
file
(
'obj.save'
,
'wb'
)
cPickle
.
dump
(
my_obj
,
f
,
protocol
=
cPickle
.
HIGHEST_PROTOCOL
)
f
.
close
()
f
=
file
(
'obj.save'
,
'rb'
)
loaded_obj
=
cPickle
.
load
(
f
)
f
.
close
()
obj1
=
my_obj
obj2
=
my_obj
obj3
=
my_obj
f
=
file
(
'objects.save'
,
'wb'
)
for
obj
in
[
obj1
,
obj2
,
obj3
]:
cPickle
.
dump
(
obj
,
f
,
protocol
=
cPickle
.
HIGHEST_PROTOCOL
)
f
.
close
()
f
=
file
(
'objects.save'
,
'rb'
)
loaded_objects
=
[]
for
i
in
range
(
3
):
loaded_objects
.
append
(
cPickle
.
load
(
f
))
f
.
close
()
# Cleanup created files
.
os
.
remove
(
'obj.save'
)
os
.
remove
(
'objects.save'
)
# Here, we work in a temporary directory in order not to clutter
# the Theano repository. Code relative to creating that dir and
# removing it afterwards should _not_ be backported to the tutorial.
from
tempfile
import
mkdtemp
tmpdir
=
mkdtemp
()
origdir
=
os
.
getcwd
()
try
:
os
.
chdir
(
tmpdir
)
f
=
file
(
'obj.save'
,
'wb'
)
cPickle
.
dump
(
my_obj
,
f
,
protocol
=
cPickle
.
HIGHEST_PROTOCOL
)
f
.
close
()
f
=
file
(
'obj.save'
,
'rb'
)
loaded_obj
=
cPickle
.
load
(
f
)
f
.
close
()
obj1
=
my_obj
obj2
=
my_obj
obj3
=
my_obj
f
=
file
(
'objects.save'
,
'wb'
)
for
obj
in
[
obj1
,
obj2
,
obj3
]:
cPickle
.
dump
(
obj
,
f
,
protocol
=
cPickle
.
HIGHEST_PROTOCOL
)
f
.
close
()
f
=
file
(
'objects.save'
,
'rb'
)
loaded_objects
=
[]
for
i
in
range
(
3
):
loaded_objects
.
append
(
cPickle
.
load
(
f
))
f
.
close
()
finally
:
# Get back to the orinal dir, and temporary one
.
os
.
chdir
(
origdir
)
shutil
.
rmtree
(
tmpdir
)
class
T_modes
(
unittest
.
TestCase
):
## All tests here belog to
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论