Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7b448dce
提交
7b448dce
authored
3月 09, 2017
作者:
notoraptor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update wrapper doc.
Simplify values_eq and values_eq_approx. Then, update test for values_eq_approx. Fix some exception type. Remove useless comment.
上级
25040e3f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
11 行增加
和
18 行删除
+11
-18
test_wrapper.py
theano/gof/tests/test_wrapper.py
+5
-3
wrapper.py
theano/gof/wrapper.py
+6
-15
没有找到文件。
theano/gof/tests/test_wrapper.py
浏览文件 @
7b448dce
...
...
@@ -217,10 +217,12 @@ class TestWrapper(TestCase):
assert
w
.
values_eq_approx
(
o1
,
o2
)
# Check value_eq_approx.
# NB: I don't know exactly which kind of differences is rejected by values_eq but accepted by values_eq_approx.
# So, I just play a little with float values.
o3
=
Wrap
(
w
,
a1
=
numpy
.
asarray
([[
1
,
2
,
3
,
4
,
5
,
6
],
[
7
,
8
,
9
,
10
,
11
,
12
]])
.
astype
(
'
floa
t32'
),
a2
=
random_tensor
.
astype
(
'float64'
),
a3
=
2000.0
)
a1
=
numpy
.
asarray
([[
1
,
2
,
3
,
4
,
5
,
6
],
[
7
,
8
,
9
,
10
,
11
,
12
]])
.
astype
(
'
in
t32'
),
a2
=
(
random_tensor
.
astype
(
'float32'
)
*
10
/
2.2
*
2.19999999999
/
10
)
.
astype
(
'float64'
),
a3
=
2000.0
-
0.00000000000000001
)
assert
w
.
values_eq_approx
(
o1
,
o3
)
def
test_op_params
(
self
):
...
...
theano/gof/wrapper.py
浏览文件 @
7b448dce
...
...
@@ -142,16 +142,16 @@ class Wrapper(Type):
structObject.key
In a C code, a
ttributes created to represent an instance of the type associated to
``key`` will be available via:
In a C code, a
ny attribute named
``key`` will be available via:
.. code-block:: c
structObject->key;
structObject->dtype_key; // e.g. from TensorType C code.
structObject->other_attribute_named_from_key;
/* etc. */
**NB**: This Type is not a complete type and should never be used for regular graph operations.
.. note::
This Type is not complete and should never be used for regular graph operations.
"""
def
__init__
(
self
,
**
kwargs
):
...
...
@@ -160,7 +160,7 @@ class Wrapper(Type):
for
attribute_name
in
kwargs
:
if
re
.
match
(
'^[A-Za-z_][A-Za-z0-9_]*$'
,
attribute_name
)
is
None
:
raise
Syntax
Error
(
'Wrapper: attribute "
%
s" should be a valid identifier.'
%
attribute_name
)
raise
Attribute
Error
(
'Wrapper: attribute "
%
s" should be a valid identifier.'
%
attribute_name
)
if
attribute_name
in
c_cpp_keywords
:
print
(
len
(
c_cpp_keywords
))
raise
SyntaxError
(
'Wrapper: "
%
s" is a potential C/C++ keyword and should not be used as attribute name.'
...
...
@@ -180,7 +180,6 @@ class Wrapper(Type):
return
'Wrapper<
%
s>'
%
', '
.
join
([(
'
%
s:
%
s'
%
(
self
.
fields
[
i
],
self
.
types
[
i
]))
for
i
in
range
(
self
.
length
)])
def
__eq__
(
self
,
other
):
# To be checked.
return
(
type
(
self
)
==
type
(
other
)
and
self
.
fields
==
other
.
fields
and
self
.
types
==
other
.
types
)
def
__hash__
(
self
):
...
...
@@ -211,18 +210,10 @@ class Wrapper(Type):
return
self
.
wrap_data
(
data
,
strict
,
allow_downcast
)
def
values_eq
(
self
,
a
,
b
):
# We check that a and b have expected attributes and strict values.
a
=
self
.
filter
(
a
,
strict
=
True
)
b
=
self
.
filter
(
b
,
strict
=
True
)
# Then we compare.
return
all
(
self
.
types
[
i
]
.
values_eq
(
getattr
(
a
,
self
.
fields
[
i
]),
getattr
(
b
,
self
.
fields
[
i
]))
for
i
in
range
(
self
.
length
))
def
values_eq_approx
(
self
,
a
,
b
):
# We check, wrap and round a and b if necessary.
a
=
self
.
filter
(
a
,
strict
=
False
,
allow_downcast
=
True
)
b
=
self
.
filter
(
b
,
strict
=
False
,
allow_downcast
=
True
)
# Then we compare.
return
all
(
self
.
types
[
i
]
.
values_eq_approx
(
getattr
(
a
,
self
.
fields
[
i
]),
getattr
(
b
,
self
.
fields
[
i
]))
for
i
in
range
(
self
.
length
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论