Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d4ff7188
提交
d4ff7188
authored
6月 08, 2011
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Small updates to compute_test_values
上级
71a8a1c9
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
21 行增加
和
11 行删除
+21
-11
op.py
theano/gof/op.py
+21
-11
没有找到文件。
theano/gof/op.py
浏览文件 @
d4ff7188
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
The `Op` class is the base interface for all operations
The `Op` class is the base interface for all operations
compatible with `gof`'s :doc:`graph` routines.
compatible with `gof`'s :doc:`graph` routines.
"""
"""
__docformat__
=
"restructuredtext en"
__docformat__
=
"restructuredtext en"
...
@@ -331,7 +329,7 @@ class PureOp(object):
...
@@ -331,7 +329,7 @@ class PureOp(object):
# build test input-values
# build test input-values
input_vals
=
[]
input_vals
=
[]
for
i
ns
in
node
.
inputs
:
for
i
,
ins
in
enumerate
(
node
.
inputs
)
:
if
isinstance
(
ins
,
graph
.
Constant
):
if
isinstance
(
ins
,
graph
.
Constant
):
input_vals
.
append
(
ins
.
value
)
input_vals
.
append
(
ins
.
value
)
elif
isinstance
(
ins
,
SharedVariable
):
elif
isinstance
(
ins
,
SharedVariable
):
...
@@ -342,10 +340,11 @@ class PureOp(object):
...
@@ -342,10 +340,11 @@ class PureOp(object):
else
:
else
:
# no test-value was specified, act accordingly
# no test-value was specified, act accordingly
if
config
.
compute_test_value
==
'warn'
:
if
config
.
compute_test_value
==
'warn'
:
raise
Warning
(
'Cannot compute test value: input
%
s of Op
%
s missing default value'
)
# TODO: use warnings.warn, http://docs.python.org/library/warnings.html#warnings.warn
print
>>
sys
.
stderr
,
(
'Warning, Cannot compute test value: input
%
i (
%
s) of Op
%
s missing default value'
%
(
i
,
ins
,
node
))
run_perform
=
False
run_perform
=
False
elif
config
.
compute_test_value
==
'err'
:
elif
config
.
compute_test_value
==
'err'
:
raise
ValueError
(
'Cannot compute test value: input
%
s of Op
%
s missing default value'
)
raise
ValueError
(
'Cannot compute test value: input
%
i (
%
s) of Op
%
s missing default value'
%
(
i
,
ins
,
node
)
)
else
:
else
:
# silently skip test
# silently skip test
run_perform
=
False
run_perform
=
False
...
@@ -355,12 +354,23 @@ class PureOp(object):
...
@@ -355,12 +354,23 @@ class PureOp(object):
# compute output value once with test inputs to validate graph
# compute output value once with test inputs to validate graph
output_storage
=
[[
None
]]
*
len
(
node
.
outputs
)
output_storage
=
[[
None
]]
*
len
(
node
.
outputs
)
node
.
op
.
perform
(
node
,
input_vals
,
output_storage
)
try
:
node
.
op
.
perform
(
node
,
input_vals
,
output_storage
)
# add 'test_value' to output tags, so that downstream ops can use these
# numerical values as inputs to their perform method.
# add 'test_value' to output tags, so that downstream ops can use these
for
(
outval
,
node_output
)
in
zip
(
output_storage
,
node
.
outputs
):
# numerical values as inputs to their perform method.
node_output
.
tag
.
test_value
=
outval
[
0
]
for
(
outval
,
node_output
)
in
zip
(
output_storage
,
node
.
outputs
):
node_output
.
tag
.
test_value
=
outval
[
0
]
except
utils
.
MethodNotDefined
,
e
:
# This case happens when the perform method is not defined
# for a certain Op.
#TODO: use the c_thunk?
if
config
.
compute_test_value
==
'warn'
:
# TODO: use warnings.warn
print
>>
sys
.
stderr
,
'Warning, in compute_test_value:'
,
type
(
e
)
print
>>
sys
.
stderr
,
e
elif
config
.
compute_test_value
==
'err'
:
raise
if
self
.
default_output
is
not
None
:
if
self
.
default_output
is
not
None
:
return
node
.
outputs
[
self
.
default_output
]
return
node
.
outputs
[
self
.
default_output
]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论