Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
fe38ef37
提交
fe38ef37
authored
9月 08, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add the theano_function.trust_input member that allow to skip check of the input…
Add the theano_function.trust_input member that allow to skip check of the input on all functions call.
上级
aeedaa73
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
21 行增加
和
3 行删除
+21
-3
function_module.py
theano/compile/function_module.py
+21
-3
没有找到文件。
theano/compile/function_module.py
浏览文件 @
fe38ef37
...
@@ -280,6 +280,13 @@ class Function(object):
...
@@ -280,6 +280,13 @@ class Function(object):
A Function instance may be serialized using the `pickle` or `cPickle` modules.
A Function instance may be serialized using the `pickle` or `cPickle` modules.
This will save all default inputs, the graph, and *** to the pickle file (WRITEME).
This will save all default inputs, the graph, and *** to the pickle file (WRITEME).
A Function instance have a ``trust_input`` field that default to
False. When True, we don't do extra check of the input to give
better error message. In some case, python code will still return
the good results if you pass a python or numpy scalar instead of a
numpy tensor. C code should raise an error if you pass an object
of the wrong type.
"""
"""
pickle_aliased_memory_strategy
=
'warn'
pickle_aliased_memory_strategy
=
'warn'
...
@@ -367,6 +374,7 @@ class Function(object):
...
@@ -367,6 +374,7 @@ class Function(object):
self
.
return_none
=
return_none
self
.
return_none
=
return_none
self
.
maker
=
maker
self
.
maker
=
maker
self
.
profile
=
None
# reassigned in FunctionMaker.create
self
.
profile
=
None
# reassigned in FunctionMaker.create
self
.
trust_input
=
False
# If True, we don't check the input parameter
# We will be popping stuff off this `containers` object. It is a copy.
# We will be popping stuff off this `containers` object. It is a copy.
containers
=
list
(
self
.
input_storage
)
containers
=
list
(
self
.
input_storage
)
...
@@ -549,6 +557,13 @@ class Function(object):
...
@@ -549,6 +557,13 @@ class Function(object):
t0
=
time
.
time
()
t0
=
time
.
time
()
# Reinitialize each container's 'provided' counter
# Reinitialize each container's 'provided' counter
if
self
.
trust_input
:
i
=
0
for
arg
in
args
:
s
=
self
.
input_storage
[
i
]
s
.
storage
[
0
]
=
arg
i
+=
1
else
:
for
c
in
self
.
input_storage
:
for
c
in
self
.
input_storage
:
c
.
provided
=
0
c
.
provided
=
0
...
@@ -589,7 +604,8 @@ class Function(object):
...
@@ -589,7 +604,8 @@ class Function(object):
for
k
,
arg
in
kwargs
.
iteritems
():
for
k
,
arg
in
kwargs
.
iteritems
():
self
[
k
]
=
arg
self
[
k
]
=
arg
if
(
not
hasattr
(
self
,
'_check_for_aliased_inputs'
)
or
if
not
self
.
trust_input
and
(
not
hasattr
(
self
,
'_check_for_aliased_inputs'
)
or
self
.
_check_for_aliased_inputs
):
self
.
_check_for_aliased_inputs
):
## Collect aliased inputs among the storage space
## Collect aliased inputs among the storage space
args_share_memory
=
[]
args_share_memory
=
[]
...
@@ -629,7 +645,8 @@ class Function(object):
...
@@ -629,7 +645,8 @@ class Function(object):
self
.
input_storage
[
i
]
.
storage
[
0
])
self
.
input_storage
[
i
]
.
storage
[
0
])
# Check if inputs are missing, or if inputs were set more than once, or
# Check if inputs are missing, or if inputs were set more than once, or
# if we tried to provide inputs that are supposed to be implicit.
# if we tried to provide inputs that are supposed to be
if
not
self
.
trust_input
:
for
c
in
self
.
input_storage
:
for
c
in
self
.
input_storage
:
if
c
.
required
and
not
c
.
provided
:
if
c
.
required
and
not
c
.
provided
:
raise
TypeError
(
"Missing required input:
%
s"
%
raise
TypeError
(
"Missing required input:
%
s"
%
...
@@ -640,7 +657,8 @@ class Function(object):
...
@@ -640,7 +657,8 @@ class Function(object):
getattr
(
self
.
inv_finder
[
c
],
'variable'
,
getattr
(
self
.
inv_finder
[
c
],
'variable'
,
self
.
inv_finder
[
c
]))
self
.
inv_finder
[
c
]))
if
c
.
implicit
and
c
.
provided
>
0
:
if
c
.
implicit
and
c
.
provided
>
0
:
raise
TypeError
(
'Tried to provide value for implicit input:
%
s'
raise
TypeError
(
'Tried to provide value for implicit input:
%
s'
%
getattr
(
self
.
inv_finder
[
c
],
'variable'
,
%
getattr
(
self
.
inv_finder
[
c
],
'variable'
,
self
.
inv_finder
[
c
]))
self
.
inv_finder
[
c
]))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论