Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
347988d8
提交
347988d8
authored
2月 05, 2015
作者:
abergeron
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2477 from nouiz/test_crash
Fix tests, crash and clean up
上级
9636481a
5b044dc4
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
27 行增加
和
32 行删除
+27
-32
debug_faq.txt
doc/tutorial/debug_faq.txt
+8
-1
debugmode.py
theano/compile/debugmode.py
+0
-3
function_module.py
theano/compile/function_module.py
+0
-6
monitormode.py
theano/compile/monitormode.py
+11
-0
link.py
theano/gof/link.py
+2
-9
op.py
theano/gof/op.py
+0
-9
test_basic.py
theano/tensor/tests/test_basic.py
+6
-4
没有找到文件。
doc/tutorial/debug_faq.txt
浏览文件 @
347988d8
...
@@ -343,9 +343,16 @@ can be achieved as follows:
...
@@ -343,9 +343,16 @@ can be achieved as follows:
import theano
import theano
# This is the current suggested detect_nan implementation to
# show you how it work. That way, you can modify it for your
# need. If you want exactly this method, you can use
# ``theano.compile.monitormode.detect_nan`` that will always
# contain the current suggested version.
def detect_nan(i, node, fn):
def detect_nan(i, node, fn):
for output in fn.outputs:
for output in fn.outputs:
if numpy.isnan(output[0]).any():
if (not isinstance(numpy.random.RandomState, output[0]) and
numpy.isnan(output[0]).any()):
print '*** NaN detected ***'
print '*** NaN detected ***'
theano.printing.debugprint(node)
theano.printing.debugprint(node)
print 'Inputs : %s' % [input[0] for input in fn.inputs]
print 'Inputs : %s' % [input[0] for input in fn.inputs]
...
...
theano/compile/debugmode.py
浏览文件 @
347988d8
...
@@ -2226,17 +2226,14 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions
...
@@ -2226,17 +2226,14 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions
# optimize the fgraph
# optimize the fgraph
compute_test_value_orig
=
theano
.
config
.
compute_test_value
compute_test_value_orig
=
theano
.
config
.
compute_test_value
add_stack_trace_on_call
=
gof
.
Op
.
add_stack_trace_on_call
try
:
try
:
theano
.
config
.
compute_test_value
=
theano
.
config
.
compute_test_value_opt
theano
.
config
.
compute_test_value
=
theano
.
config
.
compute_test_value_opt
gof
.
Op
.
add_stack_trace_on_call
=
False
# Should it be 0 == i?
optimizer
(
fgraph
)
optimizer
(
fgraph
)
theano
.
compile
.
function_module
.
insert_deepcopy
(
fgraph
,
inputs
,
theano
.
compile
.
function_module
.
insert_deepcopy
(
fgraph
,
inputs
,
outputs
+
additional_outputs
)
outputs
+
additional_outputs
)
finally
:
finally
:
theano
.
config
.
compute_test_value
=
compute_test_value_orig
theano
.
config
.
compute_test_value
=
compute_test_value_orig
gof
.
Op
.
add_stack_trace_on_call
=
add_stack_trace_on_call
if
i
:
if
i
:
li
=
fgraph
.
equivalence_tracker
.
event_list
li
=
fgraph
.
equivalence_tracker
.
event_list
...
...
theano/compile/function_module.py
浏览文件 @
347988d8
...
@@ -1235,13 +1235,11 @@ class FunctionMaker(object):
...
@@ -1235,13 +1235,11 @@ class FunctionMaker(object):
optimizer
,
linker
=
mode
.
optimizer
,
copy
.
copy
(
mode
.
linker
)
optimizer
,
linker
=
mode
.
optimizer
,
copy
.
copy
(
mode
.
linker
)
if
need_opt
:
if
need_opt
:
compute_test_value_orig
=
theano
.
config
.
compute_test_value
compute_test_value_orig
=
theano
.
config
.
compute_test_value
add_stack_trace_on_call_orig
=
gof
.
Op
.
add_stack_trace_on_call
limit_orig
=
theano
.
config
.
traceback
.
limit
limit_orig
=
theano
.
config
.
traceback
.
limit
# Why we add stack on node when it get done in output var?
# Why we add stack on node when it get done in output var?
try
:
try
:
# optimize the fgraph
# optimize the fgraph
theano
.
config
.
compute_test_value
=
theano
.
config
.
compute_test_value_opt
theano
.
config
.
compute_test_value
=
theano
.
config
.
compute_test_value_opt
gof
.
Op
.
add_stack_trace_on_call
=
False
theano
.
config
.
traceback
.
limit
=
0
theano
.
config
.
traceback
.
limit
=
0
start_optimizer
=
time
.
time
()
start_optimizer
=
time
.
time
()
...
@@ -1264,7 +1262,6 @@ class FunctionMaker(object):
...
@@ -1264,7 +1262,6 @@ class FunctionMaker(object):
insert_deepcopy
(
fgraph
,
inputs
,
outputs
+
additional_outputs
)
insert_deepcopy
(
fgraph
,
inputs
,
outputs
+
additional_outputs
)
finally
:
finally
:
theano
.
config
.
compute_test_value
=
compute_test_value_orig
theano
.
config
.
compute_test_value
=
compute_test_value_orig
gof
.
Op
.
add_stack_trace_on_call
=
add_stack_trace_on_call_orig
theano
.
config
.
traceback
.
limit
=
limit_orig
theano
.
config
.
traceback
.
limit
=
limit_orig
# initialize the linker
# initialize the linker
...
@@ -1411,15 +1408,12 @@ class FunctionMaker(object):
...
@@ -1411,15 +1408,12 @@ class FunctionMaker(object):
# Get a function instance
# Get a function instance
start_linker
=
time
.
time
()
start_linker
=
time
.
time
()
start_import_time
=
theano
.
gof
.
cmodule
.
import_time
start_import_time
=
theano
.
gof
.
cmodule
.
import_time
add_stack_trace_on_call_orig
=
gof
.
Op
.
add_stack_trace_on_call
limit_orig
=
theano
.
config
.
traceback
.
limit
limit_orig
=
theano
.
config
.
traceback
.
limit
try
:
try
:
gof
.
Op
.
add_stack_trace_on_call
=
False
theano
.
config
.
traceback
.
limit
=
0
theano
.
config
.
traceback
.
limit
=
0
_fn
,
_i
,
_o
=
self
.
linker
.
make_thunk
(
_fn
,
_i
,
_o
=
self
.
linker
.
make_thunk
(
input_storage
=
input_storage_lists
)
input_storage
=
input_storage_lists
)
finally
:
finally
:
gof
.
Op
.
add_stack_trace_on_call
=
add_stack_trace_on_call_orig
theano
.
config
.
traceback
.
limit
=
limit_orig
theano
.
config
.
traceback
.
limit
=
limit_orig
end_linker
=
time
.
time
()
end_linker
=
time
.
time
()
...
...
theano/compile/monitormode.py
浏览文件 @
347988d8
...
@@ -80,3 +80,14 @@ class MonitorMode(Mode):
...
@@ -80,3 +80,14 @@ class MonitorMode(Mode):
ret
.
pre_func
=
self
.
pre_func
ret
.
pre_func
=
self
.
pre_func
ret
.
post_func
=
self
.
post_func
ret
.
post_func
=
self
.
post_func
return
ret
return
ret
def
detect_nan
(
i
,
node
,
fn
):
for
output
in
fn
.
outputs
:
if
(
not
isinstance
(
numpy
.
random
.
RandomState
,
output
[
0
])
and
numpy
.
isnan
(
output
[
0
])
.
any
()):
print
'*** NaN detected ***'
theano
.
printing
.
debugprint
(
node
)
print
'Inputs :
%
s'
%
[
input
[
0
]
for
input
in
fn
.
inputs
]
print
'Outputs:
%
s'
%
[
output
[
0
]
for
output
in
fn
.
outputs
]
break
theano/gof/link.py
浏览文件 @
347988d8
...
@@ -101,7 +101,7 @@ def raise_with_op(node, thunk=None, exc_info=None, storage_map=None):
...
@@ -101,7 +101,7 @@ def raise_with_op(node, thunk=None, exc_info=None, storage_map=None):
# print a simple traceback from KeyboardInterrupt
# print a simple traceback from KeyboardInterrupt
raise
exc_type
,
exc_value
,
exc_trace
raise
exc_type
,
exc_value
,
exc_trace
try
:
try
:
trace
=
node
.
tag
.
trace
trace
=
node
.
outputs
[
0
]
.
tag
.
trace
except
AttributeError
:
except
AttributeError
:
try
:
try
:
trace
=
node
.
op
.
tag
.
trace
trace
=
node
.
op
.
tag
.
trace
...
@@ -114,11 +114,6 @@ def raise_with_op(node, thunk=None, exc_info=None, storage_map=None):
...
@@ -114,11 +114,6 @@ def raise_with_op(node, thunk=None, exc_info=None, storage_map=None):
else
:
else
:
exc_value
.
__applynode_index__
=
None
exc_value
.
__applynode_index__
=
None
# nose and unittest catch the exception and do not run th thunk_hook
# so it can be useful to just blurt out errors right here
if
raise_with_op
.
print_thunk_trace
:
log_thunk_trace
(
exc_value
)
hints
=
[]
hints
=
[]
detailed_err_msg
=
"
\n
Apply node that caused the error: "
+
str
(
node
)
detailed_err_msg
=
"
\n
Apply node that caused the error: "
+
str
(
node
)
...
@@ -151,7 +146,7 @@ def raise_with_op(node, thunk=None, exc_info=None, storage_map=None):
...
@@ -151,7 +146,7 @@ def raise_with_op(node, thunk=None, exc_info=None, storage_map=None):
" have the inputs shapes and strides printed."
)
" have the inputs shapes and strides printed."
)
# Print node backtrace
# Print node backtrace
tr
=
getattr
(
node
.
tag
,
'trace'
,
None
)
tr
=
getattr
(
node
.
outputs
[
0
]
.
tag
,
'trace'
,
None
)
if
tr
:
if
tr
:
sio
=
StringIO
.
StringIO
()
sio
=
StringIO
.
StringIO
()
traceback
.
print_list
(
tr
,
sio
)
traceback
.
print_list
(
tr
,
sio
)
...
@@ -210,8 +205,6 @@ def raise_with_op(node, thunk=None, exc_info=None, storage_map=None):
...
@@ -210,8 +205,6 @@ def raise_with_op(node, thunk=None, exc_info=None, storage_map=None):
'
\n
'
+
'
\n
'
.
join
(
hints
))
'
\n
'
+
'
\n
'
.
join
(
hints
))
raise
exc_type
,
exc_value
,
exc_trace
raise
exc_type
,
exc_value
,
exc_trace
raise_with_op
.
print_thunk_trace
=
False
class
Linker
(
object
):
class
Linker
(
object
):
"""WRITEME"""
"""WRITEME"""
...
...
theano/gof/op.py
浏览文件 @
347988d8
...
@@ -413,13 +413,6 @@ class PureOp(object):
...
@@ -413,13 +413,6 @@ class PureOp(object):
"""
"""
add_stack_trace_on_call
=
True
"""This class variable governs whether __call__ adds a stack trace to the node it creates.
The tag trace is meant to connect a node to the line a user typed. It is nice for
debugging. It does not make as much sense during optimizations to store this information.
"""
#############
#############
# make_node #
# make_node #
#############
#############
...
@@ -486,8 +479,6 @@ class PureOp(object):
...
@@ -486,8 +479,6 @@ class PureOp(object):
"""
"""
return_list
=
kwargs
.
pop
(
'return_list'
,
False
)
return_list
=
kwargs
.
pop
(
'return_list'
,
False
)
node
=
self
.
make_node
(
*
inputs
,
**
kwargs
)
node
=
self
.
make_node
(
*
inputs
,
**
kwargs
)
if
self
.
add_stack_trace_on_call
:
self
.
add_tag_trace
(
node
)
if
config
.
compute_test_value
!=
'off'
:
if
config
.
compute_test_value
!=
'off'
:
run_perform
=
True
run_perform
=
True
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
347988d8
...
@@ -4852,13 +4852,15 @@ def test_tile_grad():
...
@@ -4852,13 +4852,15 @@ def test_tile_grad():
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
# test vector
# test vector
grad_tile
(
vector
(
'x'
),
[
3
],
rng
.
randn
(
5
))
grad_tile
(
vector
(
'x'
),
[
3
],
rng
.
randn
(
5
)
.
astype
(
config
.
floatX
)
)
# test matrix
# test matrix
grad_tile
(
matrix
(
'x'
),
[
3
,
4
],
rng
.
randn
(
2
,
3
))
grad_tile
(
matrix
(
'x'
),
[
3
,
4
],
rng
.
randn
(
2
,
3
)
.
astype
(
config
.
floatX
)
)
# test tensor3
# test tensor3
grad_tile
(
tensor3
(
'x'
),
[
3
,
4
,
5
],
rng
.
randn
(
2
,
4
,
3
))
grad_tile
(
tensor3
(
'x'
),
[
3
,
4
,
5
],
rng
.
randn
(
2
,
4
,
3
)
.
astype
(
config
.
floatX
))
# test tensor4
# test tensor4
grad_tile
(
tensor4
(
'x'
),
[
3
,
4
,
5
,
6
],
rng
.
randn
(
2
,
4
,
3
,
5
))
grad_tile
(
tensor4
(
'x'
),
[
3
,
4
,
5
,
6
],
rng
.
randn
(
2
,
4
,
3
,
5
)
.
astype
(
config
.
floatX
))
class
TestARange
(
unittest
.
TestCase
):
class
TestARange
(
unittest
.
TestCase
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论