Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
02ccf5bd
提交
02ccf5bd
authored
7月 21, 2014
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add function_dump() to help user give us reproducable example.
上级
5f2ed7aa
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
78 行增加
和
2 行删除
+78
-2
debug_faq.txt
doc/tutorial/debug_faq.txt
+26
-0
__init__.py
theano/__init__.py
+1
-1
__init__.py
theano/compile/__init__.py
+1
-1
function.py
theano/compile/function.py
+22
-0
test_function.py
theano/compile/tests/test_function.py
+28
-0
没有找到文件。
doc/tutorial/debug_faq.txt
浏览文件 @
02ccf5bd
...
...
@@ -410,3 +410,29 @@ the function itself (a "thunk" is a concept related to closures). Here, to
get the current node's first input's shape, you'd therefore do "p
thunk.inputs[0][0].shape", which prints out "(3, 4)".
.. _faq_dump_fct:
Dumping a Function to help debug
--------------------------------
If you are reading this, there is high chance that you emailed our
mailing list and we asked you to read this section. This section
explain how to dump all the parameter passed to
``theano.function()``. This is useful to help us reproduce a problem
during compilation and it don't request you to make a self contained
example.
For this to work, we need to be able to import the code for all Op in
the graph. So if you create your own Op, we will need this
code. Otherwise, we won't be able to unpickle it. We already have all
the Ops from Theano and Pylearn2.
.. code-block:: python
# Replace this line:
theano.function(...)
# with
theano.function_dump(filename, ...)
# Where filename is a string to a file that we will write to.
Then send us filename.
theano/__init__.py
浏览文件 @
02ccf5bd
...
...
@@ -57,7 +57,7 @@ from theano.compile import \
SymbolicOutput
,
Out
,
\
Mode
,
\
predefined_modes
,
predefined_linkers
,
predefined_optimizers
,
\
FunctionMaker
,
function
,
OpFromGraph
,
\
FunctionMaker
,
function
,
function_dump
,
OpFromGraph
,
\
Component
,
External
,
Member
,
Method
,
\
Composite
,
ComponentList
,
ComponentDict
,
Module
,
\
ProfileMode
,
ProfileStats
,
\
...
...
theano/compile/__init__.py
浏览文件 @
02ccf5bd
...
...
@@ -28,4 +28,4 @@ from theano.compile.pfunc import pfunc, Param, rebuild_collect_shared
from
theano.compile.builders
import
*
from
theano.compile.function
import
function
from
theano.compile.function
import
function
,
function_dump
theano/compile/function.py
浏览文件 @
02ccf5bd
...
...
@@ -2,6 +2,7 @@
"""
__docformat__
=
"restructuredtext en"
import
cPickle
import
logging
_logger
=
logging
.
getLogger
(
'theano.compile.function'
)
...
...
@@ -12,6 +13,27 @@ from numpy import any # to work in python 2.4
import
warnings
from
theano
import
gof
def
function_dump
(
filename
,
inputs
,
outputs
=
None
,
mode
=
None
,
updates
=
None
,
givens
=
None
,
no_default_updates
=
False
,
accept_inplace
=
False
,
name
=
None
,
rebuild_strict
=
True
,
allow_input_downcast
=
None
,
profile
=
None
,
on_unused_input
=
None
):
"""This is helpful to make a reproducable case for problem during
Theano compilation.
"""
assert
isinstance
(
filename
,
basestring
)
d
=
dict
(
inputs
=
inputs
,
outputs
=
outputs
,
mode
=
mode
,
updates
=
updates
,
givens
=
givens
,
no_default_updates
=
no_default_updates
,
accept_inplace
=
accept_inplace
,
name
=
name
,
rebuild_strict
=
rebuild_strict
,
allow_input_downcast
=
allow_input_downcast
,
profile
=
profile
,
on_unused_input
=
on_unused_input
)
with
open
(
filename
,
'wb'
)
as
f
:
cPickle
.
dump
(
d
,
f
,
-
1
)
def
function
(
inputs
,
outputs
=
None
,
mode
=
None
,
updates
=
None
,
givens
=
None
,
no_default_updates
=
False
,
accept_inplace
=
False
,
name
=
None
,
rebuild_strict
=
True
,
allow_input_downcast
=
None
,
profile
=
None
,
...
...
theano/compile/tests/test_function.py
0 → 100644
浏览文件 @
02ccf5bd
import
cPickle
import
os
import
shutil
import
tempfile
import
numpy
import
theano
def
test_function_dump
():
v
=
theano
.
tensor
.
vector
()
fct1
=
theano
.
function
([
v
],
v
+
1
)
try
:
tmpdir
=
tempfile
.
mkdtemp
()
fname
=
os
.
path
.
join
(
tmpdir
,
'test_function_dump.pkl'
)
theano
.
function_dump
(
fname
,
[
v
],
v
+
1
)
f
=
open
(
fname
,
'rb'
)
l
=
cPickle
.
load
(
f
)
f
.
close
()
finally
:
if
tmpdir
is
not
None
:
shutil
.
rmtree
(
tmpdir
)
fct2
=
theano
.
function
(
**
l
)
x
=
[
1
,
2
,
3
]
assert
numpy
.
allclose
(
fct1
(
x
),
fct2
(
x
))
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论