Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
1b65de9a
提交
1b65de9a
authored
4月 07, 2017
作者:
notoraptor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update tests for ParamsType.
Update ParamsType usage in `theano/gof/op.py`.
上级
42e7ed18
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
23 行增加
和
2 行删除
+23
-2
op.py
theano/gof/op.py
+1
-1
test_params_type.py
theano/gof/tests/test_params_type.py
+22
-1
没有找到文件。
theano/gof/op.py
浏览文件 @
1b65de9a
...
@@ -808,7 +808,7 @@ class Op(utils.object2, PureOp, CLinkerOp):
...
@@ -808,7 +808,7 @@ class Op(utils.object2, PureOp, CLinkerOp):
field
=
wrapper
.
fields
[
i
]
field
=
wrapper
.
fields
[
i
]
_type
=
wrapper
.
types
[
i
]
_type
=
wrapper
.
types
[
i
]
wrap_dict
[
field
]
=
_type
.
filter
(
getattr
(
self
,
field
),
strict
=
False
,
allow_downcast
=
True
)
wrap_dict
[
field
]
=
_type
.
filter
(
getattr
(
self
,
field
),
strict
=
False
,
allow_downcast
=
True
)
return
theano
.
gof
.
Params
(
wrapper
,
**
wrap_dict
)
return
self
.
params_type
.
get_params
(
self
)
raise
theano
.
gof
.
utils
.
MethodNotDefined
(
'get_params'
)
raise
theano
.
gof
.
utils
.
MethodNotDefined
(
'get_params'
)
def
prepare_node
(
self
,
node
,
storage_map
,
compute_map
,
impl
):
def
prepare_node
(
self
,
node
,
storage_map
,
compute_map
,
impl
):
...
...
theano/gof/tests/test_params_type.py
浏览文件 @
1b65de9a
...
@@ -6,7 +6,7 @@ from theano.gof import Op, COp, Apply
...
@@ -6,7 +6,7 @@ from theano.gof import Op, COp, Apply
from
theano
import
Generic
from
theano
import
Generic
from
theano.scalar
import
Scalar
from
theano.scalar
import
Scalar
from
theano.tensor
import
TensorType
from
theano.tensor
import
TensorType
from
theano.gof
import
ParamsType
,
Params
from
theano.gof
import
ParamsType
,
Params
,
EnumList
from
theano
import
tensor
from
theano
import
tensor
from
theano.tests
import
unittest_tools
as
utt
from
theano.tests
import
unittest_tools
as
utt
...
@@ -213,6 +213,27 @@ class TestParamsType(TestCase):
...
@@ -213,6 +213,27 @@ class TestParamsType(TestCase):
a3
=
2000.0
-
0.00000000000000001
)
a3
=
2000.0
-
0.00000000000000001
)
assert
w
.
values_eq_approx
(
o1
,
o3
)
assert
w
.
values_eq_approx
(
o1
,
o3
)
def
test_params_type_with_enums
(
self
):
# Test that we fail if we create a wrapper with common enum names inside different enum types.
try
:
w
=
ParamsType
(
enum1
=
EnumList
(
'A'
,
'B'
,
'C'
),
enum2
=
EnumList
(
'A'
,
'B'
,
'F'
))
except
AttributeError
:
pass
else
:
raise
Exception
(
'ParamsType should fail with common enum names inside different enum types.'
)
# Test that we can access enum values through wrapper directly.
w
=
ParamsType
(
enum1
=
EnumList
(
'A'
,
(
'B'
,
'beta'
),
'C'
),
enum2
=
EnumList
((
'D'
,
'delta'
),
'E'
,
'F'
))
assert
w
.
A
==
0
and
w
.
B
==
1
and
w
.
C
==
2
assert
w
.
D
==
0
and
w
.
E
==
1
and
w
.
F
==
2
# Test constants access through aliases.
assert
w
.
enum_from_alias
(
'beta'
)
==
w
.
B
assert
w
.
enum_from_alias
(
'delta'
)
==
w
.
D
assert
w
.
enum_from_alias
(
'C'
)
==
w
.
C
# C is not an alias, so it should return a constant named C.
# Test that other regular wrapper attributes are still available.
assert
len
(
w
.
fields
)
==
len
(
w
.
types
)
==
w
.
length
assert
w
.
name
def
test_op_params
(
self
):
def
test_op_params
(
self
):
a
,
b
,
c
=
2
,
3
,
-
7
a
,
b
,
c
=
2
,
3
,
-
7
x
=
tensor
.
matrix
(
dtype
=
'float64'
)
x
=
tensor
.
matrix
(
dtype
=
'float64'
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论