Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d732dd05
提交
d732dd05
authored
3月 11, 2009
作者:
james@X40
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
typos in compile.module
上级
c104defb
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
14 行增加
和
9 行删除
+14
-9
module.py
theano/compile/module.py
+14
-9
没有找到文件。
theano/compile/module.py
浏览文件 @
d732dd05
...
@@ -377,6 +377,8 @@ class Method(Component):
...
@@ -377,6 +377,8 @@ class Method(Component):
self
.
mode
=
mode
self
.
mode
=
mode
def
bind
(
self
,
parent
,
name
,
dup_ok
=
True
):
def
bind
(
self
,
parent
,
name
,
dup_ok
=
True
):
"""Implement`Component.bind`"""
rval
=
super
(
Method
,
self
)
.
bind
(
parent
,
name
,
dup_ok
=
dup_ok
)
rval
=
super
(
Method
,
self
)
.
bind
(
parent
,
name
,
dup_ok
=
dup_ok
)
rval
.
resolve_all
()
rval
.
resolve_all
()
return
rval
return
rval
...
@@ -384,7 +386,7 @@ class Method(Component):
...
@@ -384,7 +386,7 @@ class Method(Component):
def
resolve
(
self
,
name
):
def
resolve
(
self
,
name
):
"""Return the Result corresponding to a given name
"""Return the Result corresponding to a given name
:param name: the name of a Result in the Module
instance containing this Metho
d
:param name: the name of a Result in the Module
to which this Method is boun
d
:type name: str
:type name: str
:rtype: `Result`
:rtype: `Result`
...
@@ -399,7 +401,7 @@ class Method(Component):
...
@@ -399,7 +401,7 @@ class Method(Component):
def
resolve_all
(
self
):
def
resolve_all
(
self
):
"""Convert all inputs, outputs, and updates specified as strings to Results.
"""Convert all inputs, outputs, and updates specified as strings to Results.
This works by searching the
containing Module for Result attributes by these names
.
This works by searching the
attribute list of the Module to which this Method is bound
.
"""
"""
def
resolve_result
(
x
,
passthrough
=
(
gof
.
Result
)):
def
resolve_result
(
x
,
passthrough
=
(
gof
.
Result
)):
if
isinstance
(
x
,
passthrough
):
if
isinstance
(
x
,
passthrough
):
...
@@ -418,10 +420,10 @@ class Method(Component):
...
@@ -418,10 +420,10 @@ class Method(Component):
passthrough
=
(
gof
.
Result
,
io
.
In
))
for
input
in
inputs
]
passthrough
=
(
gof
.
Result
,
io
.
In
))
for
input
in
inputs
]
def
resolve_outputs
():
def
resolve_outputs
():
if
isinstance
(
self
.
outputs
,
(
io
.
Out
,
gof
.
Result
,
str
,
None
)):
if
isinstance
(
self
.
outputs
,
(
io
.
Out
,
gof
.
Result
,
str
,
type
(
None
)
)):
output
=
self
.
outputs
output
=
self
.
outputs
self
.
outputs
=
resolve_result
(
output
,
self
.
outputs
=
resolve_result
(
output
,
passthrough
=
(
gof
.
Result
,
io
.
Out
,
None
))
passthrough
=
(
gof
.
Result
,
io
.
Out
,
type
(
None
)
))
else
:
else
:
outputs
=
list
(
self
.
outputs
)
outputs
=
list
(
self
.
outputs
)
self
.
outputs
=
[
resolve_result
(
output
,
self
.
outputs
=
[
resolve_result
(
output
,
...
@@ -1046,28 +1048,31 @@ class Module(ComponentDict):
...
@@ -1046,28 +1048,31 @@ class Module(ComponentDict):
self
.
__set_name__
(
value
)
self
.
__set_name__
(
value
)
return
return
def
identify_member
(
v
):
def
unpack_member_and_external
(
v
):
if
isinstance
(
v
,
(
Member
,
External
)):
if
isinstance
(
v
,
(
Member
,
External
)):
print
>>
sys
.
stderr
,
(
"WARNING: assignment of Member or External "
"objects (either directly or indirectly) to Module "
"is deprecated. Just use Result."
)
return
v
.
r
return
v
.
r
elif
isinstance
(
v
,
(
gof
.
Result
,
Method
,
Module
)):
elif
isinstance
(
v
,
(
gof
.
Result
,
Method
,
Module
)):
return
v
return
v
elif
isinstance
(
v
,(
int
,
bool
)):
elif
isinstance
(
v
,(
int
,
bool
)):
return
v
return
v
elif
isinstance
(
v
,
(
list
)):
elif
isinstance
(
v
,
(
list
)):
return
map
(
identify_member
,
v
)
return
map
(
unpack_member_and_external
,
v
)
elif
isinstance
(
v
,
(
tuple
)):
elif
isinstance
(
v
,
(
tuple
)):
return
tuple
(
map
(
identify_member
,
v
))
return
tuple
(
map
(
unpack_member_and_external
,
v
))
elif
isinstance
(
v
,
dict
):
elif
isinstance
(
v
,
dict
):
v_copy
=
dict
()
v_copy
=
dict
()
for
k
,
vv
in
v
.
iteritems
():
for
k
,
vv
in
v
.
iteritems
():
v_copy
[
k
]
=
identify_member
(
vv
)
v_copy
[
k
]
=
unpack_member_and_external
(
vv
)
return
v
return
v
else
:
else
:
# raise NotImplementedError
# raise NotImplementedError
# print "WARNING: unknow:",v
# print "WARNING: unknow:",v
return
v
return
v
value
=
identify_member
(
value
)
value
=
unpack_member_and_external
(
value
)
if
not
hasattr
(
self
,
"local_attr"
):
if
not
hasattr
(
self
,
"local_attr"
):
self
.
__dict__
[
"local_attr"
]
=
{}
self
.
__dict__
[
"local_attr"
]
=
{}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论