Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c46a0243
提交
c46a0243
authored
8月 18, 2014
作者:
f0k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added test_gemm_grads() test to test whether the gradients of GpuCorrMM are correct
上级
e456ce12
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
50 行增加
和
1 行删除
+50
-1
test_conv_cuda_ndarray.py
theano/sandbox/cuda/tests/test_conv_cuda_ndarray.py
+50
-1
没有找到文件。
theano/sandbox/cuda/tests/test_conv_cuda_ndarray.py
浏览文件 @
c46a0243
...
...
@@ -842,7 +842,6 @@ class TestConv2DGPU(unittest.TestCase):
theano_mode
=
theano_mode_orig
def
test_gemm_directly
():
for
direction
in
[
'fprop'
,
'bprop img'
,
'bprop kern'
]:
print
'Testing direction: '
+
direction
...
...
@@ -893,6 +892,56 @@ def test_gemm_directly():
print
"subsample: "
,
subsample
assert
False
def
test_gemm_grads
():
for
mode
in
'valid'
,
'full'
:
for
bs
in
range
(
1
,
5
):
for
ch
in
range
(
1
,
4
):
for
nf
in
range
(
1
,
4
):
for
rImg1
in
range
(
5
,
9
):
for
rImg2
in
range
(
5
,
9
):
for
rFlt1
in
range
(
2
,
4
):
for
rFlt2
in
range
(
2
,
4
):
for
subsx
in
range
(
1
,
3
):
for
subsy
in
range
(
1
,
3
):
ishape
=
(
bs
,
ch
,
rImg1
,
rImg2
)
kshape
=
(
nf
,
ch
,
rFlt1
,
rFlt2
)
subsample
=
(
subsx
,
subsy
)
npy_img
=
theano
.
_asarray
(
numpy
.
random
.
rand
(
*
ishape
),
dtype
=
'float32'
)
npy_kern
=
theano
.
_asarray
(
numpy
.
random
.
rand
(
*
kshape
),
dtype
=
'float32'
)
i
=
cuda_tensor4
()
k
=
cuda_tensor4
()
pad
=
'auto'
if
mode
==
'full'
else
(
0
,
0
)
# TODO: also test custom pad values
corr_op
=
theano
.
sandbox
.
cuda
.
blas
.
GpuCorrMM
(
'valid'
,
subsample
,
pad
)(
i
,
k
)
conv_op
=
tensor
.
nnet
.
conv2d
(
i
,
k
[:,:,::
-
1
,::
-
1
],
ishape
,
kshape
,
mode
,
subsample
)
f
=
theano
.
function
([
i
,
k
],
[
corr_op
,
theano
.
grad
(
corr_op
.
sum
(),
i
),
theano
.
grad
(
corr_op
.
sum
(),
k
),
conv_op
,
theano
.
grad
(
conv_op
.
sum
(),
i
),
theano
.
grad
(
conv_op
.
sum
(),
k
)],
mode
=
theano_mode
)
allvals
=
f
(
npy_img
,
npy_kern
)
for
a
,
b
,
p
in
zip
(
allvals
[:
3
],
allvals
[
3
:],
(
'fprop'
,
'bprop img'
,
'bprop kern'
)):
if
(
a
.
shape
!=
b
.
shape
)
or
not
numpy
.
allclose
(
a
,
b
,
rtol
=
1e-4
):
print
"Test failed for"
,
p
print
"mode: "
,
mode
print
"ishape: "
,
ishape
print
"kshape: "
,
kshape
print
"subsample: "
,
subsample
assert
False
def
benchmark
():
shapes_valid
=
[
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论