Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
29ecc0d6
提交
29ecc0d6
authored
3月 16, 2009
作者:
desjagui@atchoum.iro.umontreal.ca
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* Fixed bug where making empty module would crash
* Added test case to test this scenario
上级
b914ef2b
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
10 行增加
和
5 行删除
+10
-5
module.py
theano/compile/module.py
+5
-5
test_module.py
theano/compile/tests/test_module.py
+5
-0
没有找到文件。
theano/compile/module.py
浏览文件 @
29ecc0d6
...
@@ -1092,6 +1092,10 @@ class Module(ComponentDict):
...
@@ -1092,6 +1092,10 @@ class Module(ComponentDict):
"""
"""
InstanceType
=
ModuleInstance
# By default, we use build ModuleInstance
InstanceType
=
ModuleInstance
# By default, we use build ModuleInstance
def
__init__
(
self
):
super
(
Module
,
self
)
.
__init__
()
self
.
__dict__
[
"local_attr"
]
=
{}
def
__wrapper__
(
self
,
x
):
def
__wrapper__
(
self
,
x
):
"""
"""
This function is called whenever x is set as an attribute of
This function is called whenever x is set as an attribute of
...
@@ -1140,11 +1144,7 @@ class Module(ComponentDict):
...
@@ -1140,11 +1144,7 @@ class Module(ComponentDict):
# print "WARNING: unknow:",v
# print "WARNING: unknow:",v
return
v
return
v
value
=
unpack_member_and_external
(
value
)
self
.
__dict__
[
"local_attr"
][
attr
]
=
unpack_member_and_external
(
value
)
if
not
hasattr
(
self
,
"local_attr"
):
self
.
__dict__
[
"local_attr"
]
=
{}
self
.
__dict__
[
"local_attr"
][
attr
]
=
value
def
build
(
self
,
mode
,
memo
):
def
build
(
self
,
mode
,
memo
):
if
self
in
memo
:
if
self
in
memo
:
...
...
theano/compile/tests/test_module.py
浏览文件 @
29ecc0d6
...
@@ -14,6 +14,10 @@ import theano
...
@@ -14,6 +14,10 @@ import theano
#TODO: add test for module.make(member=init_value)
#TODO: add test for module.make(member=init_value)
class
T_module
(
unittest
.
TestCase
):
class
T_module
(
unittest
.
TestCase
):
def
test_empty_module
(
self
):
m
=
Module
()
m
.
make
()
def
test_whats_up_with_submembers
(
self
):
def
test_whats_up_with_submembers
(
self
):
class
Blah
(
Module
):
class
Blah
(
Module
):
def
__init__
(
self
,
stepsize
):
def
__init__
(
self
,
stepsize
):
...
@@ -504,6 +508,7 @@ def test_tuple_members():
...
@@ -504,6 +508,7 @@ def test_tuple_members():
class
Temp
(
Module
):
class
Temp
(
Module
):
def
__init__
(
self
):
def
__init__
(
self
):
super
(
Temp
,
self
)
.
__init__
()
self
.
a
=
(
1
,
1
)
self
.
a
=
(
1
,
1
)
M
=
Temp
()
M
=
Temp
()
assert
isinstance
(
M
.
a
,
tuple
)
assert
isinstance
(
M
.
a
,
tuple
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论