Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
22471e39
提交
22471e39
authored
11月 26, 2014
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Test dnn conv outputs broadcastable information.
上级
75405be7
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
20 行增加
和
12 行删除
+20
-12
dnn.py
theano/sandbox/cuda/dnn.py
+0
-1
test_conv_cuda_ndarray.py
theano/sandbox/cuda/tests/test_conv_cuda_ndarray.py
+20
-11
没有找到文件。
theano/sandbox/cuda/dnn.py
浏览文件 @
22471e39
...
@@ -516,7 +516,6 @@ class GpuDnnConvGradI(GpuDnnConvBase):
...
@@ -516,7 +516,6 @@ class GpuDnnConvGradI(GpuDnnConvBase):
# not connected to desc
# not connected to desc
return
[[
1
],
[
1
],
[
0
]]
return
[[
1
],
[
1
],
[
0
]]
def
make_node
(
self
,
kern
,
topgrad
,
desc
):
def
make_node
(
self
,
kern
,
topgrad
,
desc
):
kern
=
as_cuda_ndarray_variable
(
kern
)
kern
=
as_cuda_ndarray_variable
(
kern
)
topgrad
=
as_cuda_ndarray_variable
(
topgrad
)
topgrad
=
as_cuda_ndarray_variable
(
topgrad
)
...
...
theano/sandbox/cuda/tests/test_conv_cuda_ndarray.py
浏览文件 @
22471e39
...
@@ -35,8 +35,6 @@ if theano.config.mode == 'FAST_COMPILE':
...
@@ -35,8 +35,6 @@ if theano.config.mode == 'FAST_COMPILE':
else
:
else
:
theano_mode
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
'gpu'
)
theano_mode
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
'gpu'
)
cuda_tensor4
=
cuda
.
CudaNdarrayType
([
False
]
*
4
)
device_id
=
theano
.
sandbox
.
cuda
.
use
.
device_number
device_id
=
theano
.
sandbox
.
cuda
.
use
.
device_number
if
device_id
is
None
:
if
device_id
is
None
:
cuda
.
shared_constructor
(
numpy
.
zeros
(
2
,
dtype
=
'float32'
))
cuda
.
shared_constructor
(
numpy
.
zeros
(
2
,
dtype
=
'float32'
))
...
@@ -189,13 +187,17 @@ def _params_allgood(ishape, kshape, mode, subsample=(1, 1), img_stride=(1, 1),
...
@@ -189,13 +187,17 @@ def _params_allgood(ishape, kshape, mode, subsample=(1, 1), img_stride=(1, 1),
t0
=
time
.
time
()
t0
=
time
.
time
()
cpuval
=
py_conv
(
npy_img
,
npy_kern
,
mode
,
subsample
)
cpuval
=
py_conv
(
npy_img
,
npy_kern
,
mode
,
subsample
)
t1
=
time
.
time
()
t1
=
time
.
time
()
i
=
cuda_tensor4
()
i
=
cuda
.
CudaNdarrayType
(
k
=
cuda_tensor4
()
broadcastable
=
[
sh
==
1
for
sh
in
npy_img
.
shape
])()
k
=
cuda
.
CudaNdarrayType
(
broadcastable
=
[
sh
==
1
for
sh
in
npy_kern
.
shape
])()
op
=
theano
.
sandbox
.
cuda
.
blas
.
GpuConv
(
border_mode
=
mode
,
op
=
theano
.
sandbox
.
cuda
.
blas
.
GpuConv
(
border_mode
=
mode
,
subsample
=
subsample
,
subsample
=
subsample
,
version
=
version
,
version
=
version
,
verbose
=
verbose
,
verbose
=
verbose
,
kshp
=
compile_kshp
)(
i
,
k
)
kshp
=
compile_kshp
)(
i
,
k
)
assert
[(
sh
==
1
)
is
br
for
sh
,
br
in
zip
(
cpuval
.
shape
[:
2
],
op
.
type
.
broadcastable
[:
2
])]
f
=
theano
.
function
([
i
,
k
],
op
,
mode
=
theano_mode
)
f
=
theano
.
function
([
i
,
k
],
op
,
mode
=
theano_mode
)
if
cls
is
not
None
:
if
cls
is
not
None
:
assert
any
([
isinstance
(
node
.
op
,
cls
)
assert
any
([
isinstance
(
node
.
op
,
cls
)
...
@@ -905,8 +907,10 @@ def gemm_directly(bs, ch, nf, rImg1, rImg2, rFlt1, rFlt2, subsx, subsy,
...
@@ -905,8 +907,10 @@ def gemm_directly(bs, ch, nf, rImg1, rImg2, rFlt1, rFlt2, subsx, subsy,
npy_img
=
theano
.
_asarray
(
numpy
.
random
.
rand
(
*
ishape
),
dtype
=
'float32'
)
npy_img
=
theano
.
_asarray
(
numpy
.
random
.
rand
(
*
ishape
),
dtype
=
'float32'
)
npy_kern
=
theano
.
_asarray
(
numpy
.
random
.
rand
(
*
kshape
),
dtype
=
'float32'
)
npy_kern
=
theano
.
_asarray
(
numpy
.
random
.
rand
(
*
kshape
),
dtype
=
'float32'
)
i
=
cuda_tensor4
()
i
=
cuda
.
CudaNdarrayType
(
k
=
cuda_tensor4
()
broadcastable
=
[
sh
==
1
for
sh
in
npy_img
.
shape
])()
k
=
cuda
.
CudaNdarrayType
(
broadcastable
=
[
sh
==
1
for
sh
in
npy_kern
.
shape
])()
if
direction
==
'fprop'
:
if
direction
==
'fprop'
:
cpuval
=
py_conv
(
npy_img
,
npy_kern
,
'valid'
,
subsample
)
cpuval
=
py_conv
(
npy_img
,
npy_kern
,
'valid'
,
subsample
)
...
@@ -971,8 +975,10 @@ def conv_grad(mode, bs, ch, nf, rImg1, rImg2, rFlt1, rFlt2, subsample, op):
...
@@ -971,8 +975,10 @@ def conv_grad(mode, bs, ch, nf, rImg1, rImg2, rFlt1, rFlt2, subsample, op):
npy_img
=
theano
.
_asarray
(
numpy
.
random
.
rand
(
*
ishape
),
dtype
=
'float32'
)
npy_img
=
theano
.
_asarray
(
numpy
.
random
.
rand
(
*
ishape
),
dtype
=
'float32'
)
npy_kern
=
theano
.
_asarray
(
numpy
.
random
.
rand
(
*
kshape
),
dtype
=
'float32'
)
npy_kern
=
theano
.
_asarray
(
numpy
.
random
.
rand
(
*
kshape
),
dtype
=
'float32'
)
i
=
cuda_tensor4
()
i
=
cuda
.
CudaNdarrayType
(
k
=
cuda_tensor4
()
broadcastable
=
[
sh
==
1
for
sh
in
npy_img
.
shape
])()
k
=
cuda
.
CudaNdarrayType
(
broadcastable
=
[
sh
==
1
for
sh
in
npy_kern
.
shape
])()
# TODO: also test custom pad values
# TODO: also test custom pad values
corr_op
=
op
(
mode
,
subsample
)(
i
,
k
)
corr_op
=
op
(
mode
,
subsample
)(
i
,
k
)
...
@@ -1009,9 +1015,12 @@ def conv_grad(mode, bs, ch, nf, rImg1, rImg2, rFlt1, rFlt2, subsample, op):
...
@@ -1009,9 +1015,12 @@ def conv_grad(mode, bs, ch, nf, rImg1, rImg2, rFlt1, rFlt2, subsample, op):
allvals
=
f
(
npy_img
,
npy_kern
)
allvals
=
f
(
npy_img
,
npy_kern
)
for
a
,
b
,
p
in
zip
(
allvals
[::
2
],
allvals
[
1
::
2
],
for
a
,
b
,
oa
,
ob
,
p
in
zip
(
allvals
[::
2
],
allvals
[
1
::
2
],
(
'top'
,
'dtop/dbottom'
,
'dtop/dweight'
,
outputs
[::
2
],
outputs
[
1
::
2
],
'dtop/dbottom/dweight'
,
'dtop/dweight/dbottom'
)):
(
'top'
,
'dtop/dbottom'
,
'dtop/dweight'
,
'dtop/dbottom/dweight'
,
'dtop/dweight/dbottom'
)):
assert
oa
.
type
.
broadcastable
[:
2
]
==
ob
.
type
.
broadcastable
[:
2
]
assert_allclose
(
a
,
b
,
rtol
=
1e-4
)
assert_allclose
(
a
,
b
,
rtol
=
1e-4
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论