Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a43a8425
提交
a43a8425
authored
11月 03, 2016
作者:
Alexander Matyasko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add pool grad grad tests
上级
76aa8972
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
75 行增加
和
2 行删除
+75
-2
test_blas.py
theano/gpuarray/tests/test_blas.py
+75
-2
没有找到文件。
theano/gpuarray/tests/test_blas.py
浏览文件 @
a43a8425
...
@@ -2,21 +2,26 @@ from __future__ import absolute_import, print_function, division
...
@@ -2,21 +2,26 @@ from __future__ import absolute_import, print_function, division
from
unittest
import
TestCase
from
unittest
import
TestCase
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
import
itertools
import
itertools
import
copy
import
numpy
import
theano
import
theano
from
theano
import
gradient
from
theano
import
tensor
from
theano
import
tensor
from
theano.tests
import
unittest_tools
as
utt
from
theano.tests
import
unittest_tools
as
utt
from
theano.tensor.blas
import
gemv_inplace
,
gemm_inplace
,
_dot22
,
batched_dot
from
theano.tensor.blas
import
gemv_inplace
,
gemm_inplace
,
_dot22
,
batched_dot
from
theano.tensor.tests.test_blas
import
TestGer
,
BaseGemv
from
theano.tensor.tests.test_blas
import
TestGer
,
BaseGemv
from
theano.tensor.signal.pool
import
Pool
,
DownsampleFactorMaxGradGrad
from
..
import
gpuarray_shared_constructor
from
..
import
gpuarray_shared_constructor
from
.config
import
mode_with_gpu
from
.config
import
mode_with_gpu
,
mode_without_gpu
from
.test_basic_ops
import
makeTester
,
rand
from
.test_basic_ops
import
makeTester
,
rand
from
..blas
import
(
gpugemv_inplace
,
gpugemv_no_inplace
,
from
..blas
import
(
gpugemv_inplace
,
gpugemv_no_inplace
,
gpugemm_inplace
,
gpugemmbatch_no_inplace
,
gpugemm_inplace
,
gpugemmbatch_no_inplace
,
gpuger_inplace
,
gpuger_no_inplace
,
gpuger_inplace
,
gpuger_no_inplace
,
GpuGer
,
gpu_dot22
)
GpuGer
,
gpu_dot22
,
GpuDownsampleFactorMaxGradGrad
)
GpuGemvTester
=
makeTester
(
GpuGemvTester
=
makeTester
(
...
@@ -128,3 +133,71 @@ GpuDot22Tester = makeTester(
...
@@ -128,3 +133,71 @@ GpuDot22Tester = makeTester(
# test9=[rand(0, 0), rand(0, 0)],
# test9=[rand(0, 0), rand(0, 0)],
)
)
)
)
def
test_downsample_max_grad_grad
():
shps
=
[(
1
,
12
),
(
1
,
1
,
12
),
(
1
,
1
,
1
,
12
),
(
1
,
1
,
2
,
2
),
(
1
,
1
,
1
,
1
),
(
1
,
1
,
4
,
4
),
(
1
,
1
,
10
,
11
),
(
1
,
2
,
2
,
2
),
(
3
,
5
,
4
,
4
),
(
25
,
1
,
7
,
7
),
(
1
,
1
,
12
,
12
),
(
1
,
1
,
2
,
14
),
(
1
,
1
,
12
,
14
),
(
1
,
1
,
14
,
14
),
(
1
,
1
,
16
,
16
),
(
1
,
1
,
18
,
18
),
(
1
,
1
,
24
,
24
),
(
1
,
6
,
24
,
24
),
(
10
,
1
,
24
,
24
),
(
10
,
6
,
24
,
24
),
(
30
,
6
,
12
,
12
),
(
30
,
2
,
24
,
24
),
(
30
,
6
,
24
,
24
),
(
10
,
10
,
10
,
11
),
(
1
,
1
,
10
,
1025
),
(
1
,
1
,
10
,
1023
),
(
1
,
1
,
1025
,
10
),
(
1
,
1
,
1023
,
10
),
]
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
.
shuffle
(
shps
)
test_ds
=
(
2
,
2
),
(
3
,
2
),
(
1
,
1
)
test_st
=
(
2
,
2
),
(
3
,
2
),
(
1
,
1
)
for
shp
in
shps
:
for
ds
,
st
in
itertools
.
product
(
test_ds
,
test_st
):
if
ds
[
0
]
>
shp
[
-
2
]:
continue
if
ds
[
1
]
>
shp
[
-
1
]:
continue
for
ignore_border
in
(
True
,
False
):
# print 'test_downsample', shp, ds, st, ignore_border
ds_op
=
Pool
(
ndim
=
len
(
ds
),
ignore_border
=
ignore_border
)
a
=
theano
.
shared
(
rand
(
*
shp
),
'a'
)
ggf
=
gradient
.
Lop
(
tensor
.
grad
((
ds_op
(
tensor
.
as_tensor_variable
(
a
),
ds
,
st
)
**
2
)
.
sum
(),
a
),
a
,
a
)
ref_mode
=
copy
.
copy
(
mode_without_gpu
)
ref_mode
.
check_py_code
=
False
gpu_mode
=
copy
.
copy
(
mode_with_gpu
)
gpu_mode
.
check_py_code
=
False
gg
=
theano
.
function
([],
ggf
,
mode
=
gpu_mode
)
gg2
=
theano
.
function
([],
ggf
,
mode
=
ref_mode
)
assert
any
([
isinstance
(
node
.
op
,
GpuDownsampleFactorMaxGradGrad
)
for
node
in
gg
.
maker
.
fgraph
.
toposort
()
])
assert
any
([
isinstance
(
node
.
op
,
DownsampleFactorMaxGradGrad
)
for
node
in
gg2
.
maker
.
fgraph
.
toposort
()
])
assert
numpy
.
allclose
(
gg
(),
gg2
()),
(
shp
,
ds
,
st
,
ignore_border
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论