Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
1005832b
提交
1005832b
authored
1月 27, 2012
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add tests for arg "dtype" of tensor.mean.
上级
d7cf98bf
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
39 行增加
和
0 行删除
+39
-0
test_elemwise.py
theano/tensor/tests/test_elemwise.py
+39
-0
没有找到文件。
theano/tensor/tests/test_elemwise.py
浏览文件 @
1005832b
...
@@ -544,6 +544,45 @@ class T_sum_dtype(unittest.TestCase):
...
@@ -544,6 +544,45 @@ class T_sum_dtype(unittest.TestCase):
idx
+=
1
idx
+=
1
class
T_mean_dtype
(
unittest
.
TestCase
):
def
test_mean_default_dtype
(
self
):
"""
Test the default dtype of a mean().
"""
# We try multiple axis combinations even though axis should not matter.
axes
=
[
None
,
0
,
1
,
[
0
],
[
1
],
[
0
,
1
]]
for
idx
,
dtype
in
enumerate
(
imap
(
str
,
theano
.
scalar
.
all_types
)):
axis
=
axes
[
idx
%
len
(
axes
)]
x
=
tensor
.
matrix
(
dtype
=
dtype
)
.
mean
(
axis
=
axis
)
if
dtype
in
discrete_dtypes
:
assert
x
.
dtype
==
'float64'
else
:
assert
x
.
dtype
==
dtype
,
(
x
,
x
.
dtype
,
dtype
)
def
test_mean_custom_dtype
(
self
):
"""
Test the ability to provide your own output dtype for a mean.
"""
# We try multiple axis combinations even though axis should not matter.
axes
=
[
None
,
0
,
1
,
[
0
],
[
1
],
[
0
,
1
]]
idx
=
0
for
input_dtype
in
imap
(
str
,
theano
.
scalar
.
all_types
):
x
=
tensor
.
matrix
(
dtype
=
input_dtype
)
for
sum_dtype
in
imap
(
str
,
theano
.
scalar
.
all_types
):
axis
=
axes
[
idx
%
len
(
axes
)]
# If the inner sum cannot be created, it will raise a TypeError.
try
:
mean_var
=
x
.
mean
(
dtype
=
sum_dtype
,
axis
=
axis
)
except
TypeError
:
pass
else
:
# Executed if no TypeError was raised
if
sum_dtype
in
discrete_dtypes
:
assert
mean_var
.
dtype
==
'float64'
,
(
mean_var
.
dtype
,
sum_dtype
)
else
:
assert
mean_var
.
dtype
==
sum_dtype
,
(
mean_var
.
dtype
,
output_dtype
)
idx
+=
1
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
#unittest.main()
#unittest.main()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论