Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
175dc512
提交
175dc512
authored
10月 16, 2014
作者:
Li
提交者:
Frederic
10月 21, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pickle and unpickle done.
上级
5e70f3ac
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
27 行增加
和
56 行删除
+27
-56
config.txt
doc/library/config.txt
+10
-0
configdefaults.py
theano/configdefaults.py
+1
-0
test_graph_opt_caching.py
theano/tests/test_graph_opt_caching.py
+0
-40
test_pickle_unpickle_theano_fn.py
theano/tests/test_pickle_unpickle_theano_fn.py
+16
-16
没有找到文件。
doc/library/config.txt
浏览文件 @
175dc512
...
...
@@ -683,6 +683,16 @@ import theano and print the config variable, as in:
optimization phase. Theano user's do not need to use this. This is
to help debug shape error in Theano optimization.
.. attribute:: config.reoptimize_unpickled_function
Bool value, default: True
Theano users can use the standard python pickle tools to save a compiled
theano function. When pickling, both graph before and after the optimization
are saved, including shared variables. When set to True, the graph is
reoptimized when being unpickled. Otherwise, skip the graph optimization and
use directly the optimized graph.
.. attribute:: config.exception_verbosity
String Value: ``'low'``, ``'high'``.
...
...
theano/configdefaults.py
浏览文件 @
175dc512
...
...
@@ -547,6 +547,7 @@ AddConfigVar('check_input',
BoolParam
(
True
))
AddConfigVar
(
'cache_optimizations'
,
"WARNING: work in progress, does not work yet."
"Specify if the optimization cache should be used. This cache will"
"any optimized graph and its optimization. Actually slow downs a lot"
"the first optimization, and could possibly still contains some bugs."
...
...
theano/tests/test_graph_opt_caching.py
deleted
100644 → 0
浏览文件 @
5e70f3ac
import
unittest
import
theano
import
theano.tensor
as
T
from
theano.gof.graph
import
is_same_graph
from
theano.gof
import
FunctionGraph
from
theano.scan_module.scan_utils
import
equal_computations
def
test_graph_equivalence
():
# Test if equivalent graphs are in fact equivalent
# by using some functions in Theano
# graph g1
g1_a
=
T
.
fmatrix
(
'inputs'
)
g1_b
=
T
.
fmatrix
(
'inputs'
)
g1_y
=
T
.
sum
(
g1_a
+
g1_b
)
g1_yy
=
T
.
sum
(
g1_a
+
g1_b
)
g2_x
=
T
.
fmatrix
(
'inputs'
)
g2_y
=
g2_x
.
sum
()
g3_a
=
T
.
fmatrix
(
'inputs'
)
g3_b
=
T
.
fmatrix
(
'inputs'
)
g3_y
=
T
.
sum
(
g3_a
+
g3_b
)
assert
is_same_graph
(
g1_y
,
g2_y
)
is
False
# This does not work.
assert
is_same_graph
(
g1_y
,
g1_y
)
assert
is_same_graph
(
g1_y
,
g1_yy
)
assert
is_same_graph
(
g1_y
,
g3_y
,
givens
=
{
g1_a
:
g3_a
,
g1_b
:
g3_b
})
l1
=
theano
.
gof
.
graph
.
inputs
([
g1_y
])
l2
=
theano
.
gof
.
graph
.
inputs
([
g3_y
])
assert
len
(
l1
)
==
len
(
l2
)
#FunctionGraph([], g1_y)
#assert graphs_equal(g1_y, g3_y) == True
#assert graphs_equal(g1_y, g2_y) == False
if
__name__
==
'__main__'
:
test_graph_equivalence
()
theano/tests/test_pickle_unpickle_theano_fn.py
浏览文件 @
175dc512
...
...
@@ -33,19 +33,19 @@ def test_pickle_unpickle_with_reoptimization():
f
=
theano
.
function
([
x1
,
x2
],
y
,
updates
=
updates
)
# now pickle the compiled theano fn
pkl_path
=
open
(
'thean_fn.pkl'
,
'wb'
)
cPickle
.
dump
(
f
,
pkl_path
,
-
1
)
string_pkl
=
cPickle
.
dumps
(
f
,
-
1
)
in1
=
numpy
.
ones
((
10
,
10
),
dtype
=
floatX
)
in2
=
numpy
.
ones
((
10
,
10
),
dtype
=
floatX
)
print
'the desired value is '
,
f
(
in1
,
in2
)
# test unpickle with optimization
theano
.
config
.
reoptimize_unpickled_function
=
True
# the default is True
pkl_path
=
open
(
'thean_fn.pkl'
,
'r'
)
f_
=
cPickle
.
load
(
pkl_path
)
print
'got value '
,
f_
(
in1
,
in2
)
assert
f
(
in1
,
in2
)
==
f_
(
in1
,
in2
)
default
=
theano
.
config
.
reoptimize_unpickled_function
try
:
theano
.
config
.
reoptimize_unpickled_function
=
True
# the default is True
f_
=
cPickle
.
loads
(
string_pkl
)
assert
f
(
in1
,
in2
)
==
f_
(
in1
,
in2
)
finally
:
theano
.
config
.
reoptimize_unpickled_function
=
default
def
test_pickle_unpickle_without_reoptimization
():
x1
=
T
.
fmatrix
(
'x1'
)
...
...
@@ -60,20 +60,20 @@ def test_pickle_unpickle_without_reoptimization():
f
=
theano
.
function
([
x1
,
x2
],
y
,
updates
=
updates
)
# now pickle the compiled theano fn
pkl_path
=
open
(
'thean_fn.pkl'
,
'wb'
)
cPickle
.
dump
(
f
,
pkl_path
,
-
1
)
string_pkl
=
cPickle
.
dumps
(
f
,
-
1
)
# compute f value
in1
=
numpy
.
ones
((
10
,
10
),
dtype
=
floatX
)
in2
=
numpy
.
ones
((
10
,
10
),
dtype
=
floatX
)
print
'the desired value is '
,
f
(
in1
,
in2
)
# test unpickle without optimization
theano
.
config
.
reoptimize_unpickled_function
=
False
# the default is True
pkl_path
=
open
(
'thean_fn.pkl'
,
'r'
)
f_
=
cPickle
.
load
(
pkl_path
)
print
'got value '
,
f_
(
in1
,
in2
)
assert
f
(
in1
,
in2
)
==
f_
(
in1
,
in2
)
default
=
theano
.
config
.
reoptimize_unpickled_function
try
:
theano
.
config
.
reoptimize_unpickled_function
=
False
# the default is True
f_
=
cPickle
.
loads
(
string_pkl
)
assert
f
(
in1
,
in2
)
==
f_
(
in1
,
in2
)
finally
:
theano
.
config
.
reoptimize_unpickled_function
=
default
if
__name__
==
'__main__'
:
test_pickle_unpickle_with_reoptimization
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论