Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
cc0db312
提交
cc0db312
authored
4月 15, 2016
作者:
Frederic Bastien
提交者:
Samira Shabanian
4月 19, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor how we print variable stacktrace and fix errors with trace in unpickled graph.
上级
037fd298
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
24 行增加
和
35 行删除
+24
-35
op.py
theano/gof/op.py
+3
-21
utils.py
theano/gof/utils.py
+19
-0
gradient.py
theano/gradient.py
+2
-14
没有找到文件。
theano/gof/op.py
浏览文件 @
cc0db312
...
...
@@ -13,7 +13,6 @@ import numpy
import
os
import
re
import
sys
import
traceback
import
warnings
import
theano
...
...
@@ -21,7 +20,6 @@ from theano import config
import
theano.gof.cc
from
six
import
itervalues
from
six.moves
import
StringIO
from
theano.gof
import
graph
from
theano.gof
import
utils
from
theano.gof.cmodule
import
GCC_compiler
...
...
@@ -554,16 +552,7 @@ class PureOp(object):
detailed_err_msg
=
(
"For compute_test_value, one input test value does not"
" have the requested type.
\n
"
)
tr
=
getattr
(
v
.
tag
,
'trace'
,
[])
if
isinstance
(
tr
,
list
)
and
len
(
tr
)
>
0
:
detailed_err_msg
+=
(
"
\n
Backtrace when that variable is created:
\n
"
)
# Print separate message for each element in the list
# of batcktraces
sio
=
StringIO
()
for
subtr
in
tr
:
traceback
.
print_list
(
subtr
,
sio
)
detailed_err_msg
+=
str
(
sio
.
getvalue
())
detailed_err_msg
+=
utils
.
get_variable_trace_string
(
v
)
detailed_err_msg
+=
(
"
\n
The error when converting the test value to that"
...
...
@@ -575,11 +564,7 @@ class PureOp(object):
e
.
args
=
(
"
\n
"
.
join
(
args
),)
raise
return
ret
sio
=
StringIO
()
for
subtr
in
getattr
(
v
.
tag
,
"trace"
,
[]):
traceback
.
print_list
(
subtr
,
sio
)
detailed_err_msg
=
sio
.
getvalue
()
detailed_err_msg
=
utils
.
get_variable_trace_string
(
v
)
raise
AttributeError
(
'
%
s has no test value
%
s'
%
(
v
,
detailed_err_msg
))
def
__call__
(
self
,
*
inputs
,
**
kwargs
):
...
...
@@ -634,10 +619,7 @@ class PureOp(object):
(
i
,
ins
,
node
),
stacklevel
=
2
)
run_perform
=
False
elif
config
.
compute_test_value
==
'raise'
:
sio
=
StringIO
()
for
subtr
in
getattr
(
ins
.
tag
,
"trace"
,
[]):
traceback
.
print_list
(
subtr
,
sio
)
detailed_err_msg
=
sio
.
getvalue
()
detailed_err_msg
=
utils
.
get_variable_trace_string
(
ins
)
raise
ValueError
(
'Cannot compute test value: input
%
i (
%
s) of Op
%
s missing default value.
%
s'
%
...
...
theano/gof/utils.py
浏览文件 @
cc0db312
from
__future__
import
absolute_import
,
print_function
,
division
import
linecache
import
sys
import
traceback
import
numpy
from
six
import
iteritems
,
integer_types
,
string_types
from
six.moves
import
StringIO
from
theano
import
config
from
theano.compat
import
OrderedDict
,
PY3
...
...
@@ -112,6 +114,23 @@ def add_tag_trace(thing, user_line=None):
return
thing
def
get_variable_trace_string
(
v
):
sio
=
StringIO
()
# For backward compatibility with old trace
tr
=
getattr
(
v
.
tag
,
'trace'
,
[])
if
isinstance
(
tr
,
list
)
and
len
(
tr
)
>
0
:
print
(
"
\n
Backtrace when that variable is created:
\n
"
,
file
=
sio
)
# The isinstance is needed to handle old pickled trace
if
isinstance
(
tr
[
0
],
tuple
):
traceback
.
print_list
(
v
.
tag
.
trace
,
sio
)
else
:
# Print separate message for each element in the list of
# batcktraces
for
subtr
in
tr
:
traceback
.
print_list
(
subtr
,
sio
)
return
sio
.
getvalue
()
def
hashtype
(
self
):
t
=
type
(
self
)
return
hash
(
t
.
__name__
)
^
hash
(
t
.
__module__
)
...
...
theano/gradient.py
浏览文件 @
cc0db312
...
...
@@ -3,17 +3,15 @@ from __future__ import absolute_import, print_function, division
import
six.moves.builtins
as
builtins
import
logging
import
time
import
traceback
import
warnings
import
numpy
# for numeric_grad
from
six
import
itervalues
from
six.moves
import
StringIO
import
theano
from
theano
import
gof
from
theano.gof
import
Variable
from
theano.gof
import
utils
,
Variable
from
theano.compat
import
OrderedDict
,
izip
from
six.moves
import
xrange
,
reduce
from
theano.gof.null_type
import
NullType
,
null_type
...
...
@@ -518,17 +516,7 @@ def grad(cost, wrt, consider_constant=None,
elif
disconnected_inputs
==
'warn'
:
warnings
.
warn
(
message
,
stacklevel
=
2
)
elif
disconnected_inputs
==
'raise'
:
# Add the var trace
tr
=
getattr
(
var
.
tag
,
'trace'
,
[])
if
len
(
tr
)
>
0
:
message
+=
"
\n
Backtrace when the node is created:
\n
"
# Print separate message for each element in the list of batcktraces
sio
=
StringIO
()
for
subtr
in
tr
:
traceback
.
print_list
(
subtr
,
sio
)
message
+=
str
(
sio
.
getvalue
())
message
=
utils
.
get_variable_trace_string
(
var
)
raise
DisconnectedInputError
(
message
)
else
:
raise
ValueError
(
"Invalid value for keyword "
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论