Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
8fc19902
提交
8fc19902
authored
2月 20, 2015
作者:
abergeron
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2504 from nouiz/err_msg
Better error message when the test_value do not have the right type
上级
00ed78d2
848e1501
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
48 行增加
和
9 行删除
+48
-9
configdefaults.py
theano/configdefaults.py
+2
-1
op.py
theano/gof/op.py
+28
-2
type.py
theano/gof/type.py
+1
-2
utils.py
theano/gof/utils.py
+16
-3
basic.py
theano/tensor/basic.py
+1
-1
没有找到文件。
theano/configdefaults.py
浏览文件 @
8fc19902
...
@@ -295,7 +295,8 @@ AddConfigVar('traceback.limit',
...
@@ -295,7 +295,8 @@ AddConfigVar('traceback.limit',
"The number of stack to trace. -1 mean all."
,
"The number of stack to trace. -1 mean all."
,
# We default to 6 to be able to know where v1 + v2 is created in the
# We default to 6 to be able to know where v1 + v2 is created in the
# user script. The bigger this number is, the more run time it takes.
# user script. The bigger this number is, the more run time it takes.
IntParam
(
6
),
# We need to default to 7 to support theano.tensor.tensor(...).
IntParam
(
7
),
in_c_key
=
False
)
in_c_key
=
False
)
AddConfigVar
(
'experimental.mrg'
,
AddConfigVar
(
'experimental.mrg'
,
...
...
theano/gof/op.py
浏览文件 @
8fc19902
...
@@ -16,8 +16,10 @@ import inspect
...
@@ -16,8 +16,10 @@ import inspect
import
logging
import
logging
import
numpy
import
numpy
import
os
import
os
import
sys
import
re
import
re
import
StringIO
import
sys
import
traceback
import
warnings
import
warnings
import
theano
import
theano
...
@@ -448,7 +450,31 @@ class PureOp(object):
...
@@ -448,7 +450,31 @@ class PureOp(object):
return
v
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)
return
v
.
get_value
(
borrow
=
True
,
return_internal_type
=
True
)
elif
isinstance
(
v
,
graph
.
Variable
)
and
hasattr
(
v
.
tag
,
'test_value'
):
elif
isinstance
(
v
,
graph
.
Variable
)
and
hasattr
(
v
.
tag
,
'test_value'
):
# ensure that the test value is correct
# ensure that the test value is correct
return
v
.
type
.
filter
(
v
.
tag
.
test_value
)
try
:
ret
=
v
.
type
.
filter
(
v
.
tag
.
test_value
)
except
Exception
,
e
:
# Better error message.
detailed_err_msg
=
(
"For compute_test_value, one input test value does not"
" have the requested type.
\n
"
)
tr
=
getattr
(
v
.
tag
,
'trace'
,
None
)
if
tr
:
sio
=
StringIO
.
StringIO
()
traceback
.
print_list
(
tr
,
sio
)
tr
=
sio
.
getvalue
()
detailed_err_msg
+=
(
"
\n
Backtrace when that variable is created:
\n
"
)
detailed_err_msg
+=
str
(
tr
)
detailed_err_msg
+=
(
"
\n
The error when converting the test value to that"
" variable type:"
)
# We need to only have 1 args and it should be of type
# string. Otherwise, it print the tuple and so the
# new line do not get printed.
args
=
(
detailed_err_msg
,)
+
tuple
(
str
(
arg
)
for
arg
in
e
.
args
)
e
.
args
=
(
"
\n
"
.
join
(
args
),)
raise
return
ret
raise
AttributeError
(
'
%
s has no test value'
%
v
)
raise
AttributeError
(
'
%
s has no test value'
%
v
)
...
...
theano/gof/type.py
浏览文件 @
8fc19902
...
@@ -307,8 +307,7 @@ class PureType(object):
...
@@ -307,8 +307,7 @@ class PureType(object):
def
make_constant
(
self
,
value
,
name
=
None
):
def
make_constant
(
self
,
value
,
name
=
None
):
return
self
.
Constant
(
type
=
self
,
data
=
value
,
name
=
name
)
return
self
.
Constant
(
type
=
self
,
data
=
value
,
name
=
name
)
def
__call__
(
self
,
name
=
None
):
def
__call__
(
self
,
name
=
None
):
"""Return a new `Variable` instance of Type `self`.
"""Return a new `Variable` instance of Type `self`.
:Parameters:
:Parameters:
...
...
theano/gof/utils.py
浏览文件 @
8fc19902
...
@@ -50,10 +50,16 @@ if sys.version_info[:2] > (3, 4):
...
@@ -50,10 +50,16 @@ if sys.version_info[:2] > (3, 4):
simple_extract_stack
=
traceback
.
extract_stack
simple_extract_stack
=
traceback
.
extract_stack
def
add_tag_trace
(
thing
):
def
add_tag_trace
(
thing
,
user_line
=
1
):
"""Add tag.trace to an node or variable.
"""Add tag.trace to an node or variable.
The argument is returned after being affected (inplace).
The argument is returned after being affected (inplace).
:param thing: the object where we add .tag.trace
:param user_line: The max number of user line to keep.
:note: we alse use config.traceback.limit for the maximum number
of stack level we look.
"""
"""
limit
=
config
.
traceback
.
limit
limit
=
config
.
traceback
.
limit
if
limit
==
-
1
:
if
limit
==
-
1
:
...
@@ -68,14 +74,21 @@ def add_tag_trace(thing):
...
@@ -68,14 +74,21 @@ def add_tag_trace(thing):
file_path
=
tr
[
-
1
][
0
]
file_path
=
tr
[
-
1
][
0
]
rm
=
False
rm
=
False
for
p
in
[
"theano/tensor/"
,
for
p
in
[
"theano/tensor/"
,
"theano/gof/"
]:
"theano/gof/"
,
"theano/scalar/basic.py"
,
"theano/sandbox/"
,
"theano/scan_module/"
,
"theano/sparse/"
,
"theano/typed_list/"
,
]:
if
p
in
file_path
:
if
p
in
file_path
:
tr
=
tr
[:
-
1
]
tr
=
tr
[:
-
1
]
rm
=
True
rm
=
True
break
break
if
not
rm
:
if
not
rm
:
break
break
if
len
(
tr
)
>
user_line
:
tr
=
tr
[:
user_line
]
thing
.
tag
.
trace
=
tr
thing
.
tag
.
trace
=
tr
return
thing
return
thing
...
...
theano/tensor/basic.py
浏览文件 @
8fc19902
...
@@ -744,7 +744,7 @@ def get_scalar_constant_value(orig_v, elemwise=True):
...
@@ -744,7 +744,7 @@ def get_scalar_constant_value(orig_v, elemwise=True):
def
tensor
(
*
args
,
**
kwargs
):
def
tensor
(
*
args
,
**
kwargs
):
name
=
kwargs
.
pop
(
'name'
,
None
)
name
=
kwargs
.
pop
(
'name'
,
None
)
return
TensorType
(
*
args
,
**
kwargs
)
.
make_variable
(
name
=
name
)
return
TensorType
(
*
args
,
**
kwargs
)(
name
=
name
)
def
_multi
(
*
fns
):
def
_multi
(
*
fns
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论