Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
72e2da25
提交
72e2da25
authored
12月 22, 2021
作者:
Anatoly
提交者:
Brandon T. Willard
1月 03, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add tests for out_shape input check
上级
cf7dc4a8
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
27 行增加
和
20 行删除
+27
-20
test_pool.py
tests/tensor/signal/test_pool.py
+27
-20
没有找到文件。
tests/tensor/signal/test_pool.py
浏览文件 @
72e2da25
...
@@ -12,6 +12,7 @@ from aesara.tensor.signal.pool import (
...
@@ -12,6 +12,7 @@ from aesara.tensor.signal.pool import (
AveragePoolGrad
,
AveragePoolGrad
,
DownsampleFactorMaxGradGrad
,
DownsampleFactorMaxGradGrad
,
MaxPoolGrad
,
MaxPoolGrad
,
PoolGrad
,
Pool
,
Pool
,
max_pool_2d_same_size
,
max_pool_2d_same_size
,
pool_2d
,
pool_2d
,
...
@@ -1292,23 +1293,32 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
...
@@ -1292,23 +1293,32 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
utt
.
assert_allclose
(
var_y
,
fix_y
)
utt
.
assert_allclose
(
var_y
,
fix_y
)
utt
.
assert_allclose
(
var_dx
,
fix_dx
)
utt
.
assert_allclose
(
var_dx
,
fix_dx
)
def
test_pool_2d_checks
(
self
):
@staticmethod
x
=
fmatrix
()
def
checks_helper
(
func
,
x
,
ws
,
stride
,
pad
):
with
pytest
.
raises
(
with
pytest
.
raises
(
ValueError
,
ValueError
,
match
=
r"You can't provide a tuple value to both 'ws' and 'ds'."
):
match
=
r"You can't provide a tuple value to both 'ws' and 'ds'."
):
pool_2d
(
input
=
x
,
ds
=
(
1
,
1
),
ws
=
(
1
,
1
)
)
func
(
x
,
ds
=
ws
,
ws
=
ws
)
with
pytest
.
raises
(
with
pytest
.
raises
(
ValueError
,
ValueError
,
match
=
"You must provide a tuple value for the window size."
):
match
=
"You must provide a tuple value for the window size."
):
pool_2d
(
input
=
x
)
func
(
x
)
with
pytest
.
raises
(
with
pytest
.
raises
(
ValueError
,
ValueError
,
match
=
r"You can't provide a tuple value to both 'st and 'stride'."
):
match
=
r"You can't provide a tuple value to both 'st and 'stride'."
):
pool_2d
(
input
=
x
,
ws
=
(
1
,
1
),
st
=
(
1
,
1
),
stride
=
(
1
,
1
))
func
(
x
,
ws
=
ws
,
st
=
stride
,
stride
=
stride
)
with
pytest
.
raises
(
ValueError
,
match
=
r"You can't provide a tuple value to both 'padding' and pad."
):
func
(
x
,
ws
=
ws
,
pad
=
pad
,
padding
=
pad
)
def
test_pool_2d_checks
(
self
):
x
=
fmatrix
()
self
.
checks_helper
(
pool_2d
,
x
,
ws
=
(
1
,
1
),
stride
=
(
1
,
1
),
pad
=
(
1
,
1
))
with
pytest
.
raises
(
with
pytest
.
raises
(
NotImplementedError
,
NotImplementedError
,
...
@@ -1322,20 +1332,7 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
...
@@ -1322,20 +1332,7 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
def
test_pool_3d_checks
(
self
):
def
test_pool_3d_checks
(
self
):
x
=
ftensor3
()
x
=
ftensor3
()
with
pytest
.
raises
(
self
.
checks_helper
(
pool_3d
,
x
,
ws
=
(
1
,
1
,
1
),
stride
=
(
1
,
1
,
1
),
pad
=
(
1
,
1
,
1
))
ValueError
,
match
=
r"You can't provide a tuple value to both 'ws' and 'ds'."
):
pool_3d
(
input
=
x
,
ds
=
(
1
,
1
,
1
),
ws
=
(
1
,
1
,
1
))
with
pytest
.
raises
(
ValueError
,
match
=
"You must provide a tuple value for the window size."
):
pool_3d
(
input
=
x
)
with
pytest
.
raises
(
ValueError
,
match
=
r"You can't provide a tuple value to both 'st and 'stride'"
):
pool_3d
(
input
=
x
,
ws
=
(
1
,
1
,
1
),
st
=
(
1
,
1
,
1
),
stride
=
(
1
,
1
,
1
))
with
pytest
.
raises
(
with
pytest
.
raises
(
NotImplementedError
,
NotImplementedError
,
...
@@ -1346,3 +1343,13 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
...
@@ -1346,3 +1343,13 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
out
=
pool_3d
(
input
=
x
,
ws
=
(
1
,
1
,
1
))
out
=
pool_3d
(
input
=
x
,
ws
=
(
1
,
1
,
1
))
assert
not
out
.
owner
.
op
.
ignore_border
assert
not
out
.
owner
.
op
.
ignore_border
@pytest.mark.parametrize
(
"func"
,
[
Pool
.
out_shape
,
PoolGrad
.
out_shape
])
def
test_Pool_out_shape_checks
(
self
,
func
):
x
=
(
10
,
10
)
self
.
checks_helper
(
func
,
x
,
ws
=
(
1
,
1
),
stride
=
(
1
,
1
),
pad
=
(
1
,
1
))
with
pytest
.
raises
(
TypeError
,
match
=
"imgshape must have at least 3 dimensions"
):
func
(
x
,
(
2
,
2
),
ndim
=
3
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论