Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e96b7c4d
提交
e96b7c4d
authored
11月 04, 2014
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pep8
上级
28d64c99
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
16 行增加
和
9 行删除
+16
-9
test_dnn.py
theano/sandbox/cuda/tests/test_dnn.py
+16
-9
没有找到文件。
theano/sandbox/cuda/tests/test_dnn.py
浏览文件 @
e96b7c4d
...
@@ -12,7 +12,7 @@ from theano.tensor.signal.downsample import max_pool_2d
...
@@ -12,7 +12,7 @@ from theano.tensor.signal.downsample import max_pool_2d
# Skip test if cuda_ndarray is not available.
# Skip test if cuda_ndarray is not available.
import
theano.sandbox.cuda
as
cuda
import
theano.sandbox.cuda
as
cuda
if
cuda
.
cuda_available
==
Fals
e
:
if
not
cuda
.
cuda_availabl
e
:
raise
SkipTest
(
'Optional package cuda disabled'
)
raise
SkipTest
(
'Optional package cuda disabled'
)
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
...
@@ -24,13 +24,15 @@ else:
...
@@ -24,13 +24,15 @@ else:
mode_without_gpu
=
theano
.
compile
.
mode
.
get_default_mode
()
.
excluding
(
'gpu'
)
mode_without_gpu
=
theano
.
compile
.
mode
.
get_default_mode
()
.
excluding
(
'gpu'
)
def
pool_2d_i2n
(
input
,
ds
=
(
2
,
2
),
strides
=
None
,
def
pool_2d_i2n
(
input
,
ds
=
(
2
,
2
),
strides
=
None
,
pool_function
=
T
.
max
,
mode
=
'ignore_borders'
):
pool_function
=
T
.
max
,
mode
=
'ignore_borders'
):
if
strides
is
None
:
if
strides
is
None
:
strides
=
ds
strides
=
ds
if
strides
[
0
]
>
ds
[
0
]
or
strides
[
1
]
>
ds
[
1
]:
if
strides
[
0
]
>
ds
[
0
]
or
strides
[
1
]
>
ds
[
1
]:
raise
RuntimeError
(
"strides should be smaller than or equal to ds, strides=(
%
d,
%
d) and ds=(
%
d,
%
d)"
%
raise
RuntimeError
(
"strides should be smaller than or equal to ds,"
" strides=(
%
d,
%
d) and ds=(
%
d,
%
d)"
%
(
strides
+
ds
))
(
strides
+
ds
))
shape
=
input
.
shape
shape
=
input
.
shape
...
@@ -40,7 +42,8 @@ def pool_2d_i2n(input, ds=(2, 2), strides=None, pool_function=T.max, mode='ignor
...
@@ -40,7 +42,8 @@ def pool_2d_i2n(input, ds=(2, 2), strides=None, pool_function=T.max, mode='ignor
output_width
=
(
shape
[
2
]
-
ds
[
0
])
//
strides
[
0
]
+
1
output_width
=
(
shape
[
2
]
-
ds
[
0
])
//
strides
[
0
]
+
1
output_height
=
(
shape
[
3
]
-
ds
[
1
])
//
strides
[
1
]
+
1
output_height
=
(
shape
[
3
]
-
ds
[
1
])
//
strides
[
1
]
+
1
pooled_output
=
pooled_neibs
.
reshape
((
shape
[
0
],
shape
[
1
],
output_width
,
output_height
))
pooled_output
=
pooled_neibs
.
reshape
((
shape
[
0
],
shape
[
1
],
output_width
,
output_height
))
return
pooled_output
return
pooled_output
...
@@ -53,20 +56,24 @@ def test_pooling():
...
@@ -53,20 +56,24 @@ def test_pooling():
for
func
in
(
T
.
max
,
T
.
mean
):
for
func
in
(
T
.
max
,
T
.
mean
):
for
ws
in
(
4
,
5
):
for
ws
in
(
4
,
5
):
for
stride
in
(
2
,
3
):
for
stride
in
(
2
,
3
):
out1
=
cuda
.
dnn
.
dnn_pool
(
x
,
ws
=
(
ws
,
ws
),
stride
=
(
stride
,
stride
),
out1
=
cuda
.
dnn
.
dnn_pool
(
x
,
ws
=
(
ws
,
ws
),
stride
=
(
stride
,
stride
),
mode
=
'max'
if
func
is
T
.
max
else
"average"
)
mode
=
'max'
if
func
is
T
.
max
else
"average"
)
out2
=
pool_2d_i2n
(
x
,
ds
=
(
ws
,
ws
),
strides
=
(
stride
,
stride
),
out2
=
pool_2d_i2n
(
x
,
ds
=
(
ws
,
ws
),
strides
=
(
stride
,
stride
),
pool_function
=
func
)
pool_function
=
func
)
f1
=
theano
.
function
([
x
],
out1
,
mode
=
mode_with_gpu
)
f1
=
theano
.
function
([
x
],
out1
,
mode
=
mode_with_gpu
)
f2
=
theano
.
function
([
x
],
out2
,
mode
=
mode_with_gpu
)
f2
=
theano
.
function
([
x
],
out2
,
mode
=
mode_with_gpu
)
data
=
numpy
.
random
.
normal
(
0
,
1
,
(
1
,
10
,
100
,
100
))
.
astype
(
"float32"
)
data
=
numpy
.
random
.
normal
(
0
,
1
,
(
1
,
10
,
100
,
100
))
.
astype
(
"float32"
)
a
=
f1
(
data
)
.
__array__
()
a
=
f1
(
data
)
.
__array__
()
b
=
f2
(
data
)
.
__array__
()
b
=
f2
(
data
)
.
__array__
()
assert
numpy
.
allclose
(
a
,
b
,
atol
=
numpy
.
finfo
(
numpy
.
float32
)
.
eps
)
assert
numpy
.
allclose
(
a
,
b
,
atol
=
numpy
.
finfo
(
numpy
.
float32
)
.
eps
)
def
test_pooling_opt
():
def
test_pooling_opt
():
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论