Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6a3cc5b1
提交
6a3cc5b1
authored
4月 12, 2017
作者:
amrithasuresh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated numpy as np
上级
9614222e
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
17 行增加
和
17 行删除
+17
-17
test_conv.py
theano/tensor/nnet/tests/test_conv.py
+17
-17
没有找到文件。
theano/tensor/nnet/tests/test_conv.py
浏览文件 @
6a3cc5b1
...
...
@@ -2,7 +2,7 @@ from __future__ import absolute_import, print_function, division
import
time
from
nose.plugins.skip
import
SkipTest
import
numpy
import
numpy
as
np
import
theano
import
theano.tensor
as
T
from
theano.tests
import
unittest_tools
as
utt
...
...
@@ -79,8 +79,8 @@ class TestConv2D(utt.InferShapeTester):
theano_conv
=
theano
.
function
([
input
,
filters
],
output
,
mode
=
self
.
mode
)
# initialize input and compute result
image_data
=
n
umpy
.
random
.
random
(
N_image_shape
)
.
astype
(
self
.
dtype
)
filter_data
=
n
umpy
.
random
.
random
(
N_filter_shape
)
.
astype
(
self
.
dtype
)
image_data
=
n
p
.
random
.
random
(
N_image_shape
)
.
astype
(
self
.
dtype
)
filter_data
=
n
p
.
random
.
random
(
N_filter_shape
)
.
astype
(
self
.
dtype
)
try
:
theano_output
=
theano_conv
(
image_data
,
filter_data
)
except
ValueError
:
...
...
@@ -97,18 +97,18 @@ class TestConv2D(utt.InferShapeTester):
orig_image_data
=
image_data
if
border_mode
is
not
'full'
:
s
=
-
1.
out_shape2d
=
n
umpy
.
array
(
N_image_shape
[
-
2
:])
+
\
s
*
n
umpy
.
array
(
N_filter_shape
[
-
2
:])
-
s
out_shape2d
=
n
umpy
.
ceil
(
out_shape2d
/
numpy
.
array
(
subsample
))
out_shape2d
=
n
p
.
array
(
N_image_shape
[
-
2
:])
+
\
s
*
n
p
.
array
(
N_filter_shape
[
-
2
:])
-
s
out_shape2d
=
n
p
.
ceil
(
out_shape2d
/
np
.
array
(
subsample
))
# avoid numpy deprecation
out_shape2d
=
out_shape2d
.
astype
(
'int32'
)
out_shape
=
(
N_image_shape
[
0
],
N_filter_shape
[
0
])
+
tuple
(
out_shape2d
)
ref_output
=
n
umpy
.
zeros
(
out_shape
)
ref_output
=
n
p
.
zeros
(
out_shape
)
# loop over output feature maps
ref_output
.
fill
(
0
)
if
border_mode
==
'full'
:
image_data2
=
n
umpy
.
zeros
((
N_image_shape
[
0
],
N_image_shape
[
1
],
image_data2
=
n
p
.
zeros
((
N_image_shape
[
0
],
N_image_shape
[
1
],
N_image_shape
[
2
]
+
2
*
N_filter_shape
[
2
]
-
2
,
N_image_shape
[
3
]
+
2
*
N_filter_shape
[
3
]
-
2
))
image_data2
[
...
...
@@ -160,17 +160,17 @@ class TestConv2D(utt.InferShapeTester):
def
test_uint_image_shape_datatype
(
self
):
"""Tests for uint datatype in image_shape.
"""
self
.
validate
((
2
,
2
,
3
,
n
umpy
.
uint8
(
3
)),
(
3
,
2
,
3
,
3
),
'valid'
,
verify_grad
=
False
)
self
.
validate
((
n
umpy
.
uint16
(
2
),
2
,
3
,
3
),
(
3
,
2
,
3
,
3
),
'valid'
,
verify_grad
=
False
)
self
.
validate
((
2
,
n
umpy
.
uint32
(
2
),
3
,
3
),
(
3
,
2
,
3
,
3
),
'valid'
,
verify_grad
=
False
)
self
.
validate
((
2
,
2
,
3
,
n
p
.
uint8
(
3
)),
(
3
,
2
,
3
,
3
),
'valid'
,
verify_grad
=
False
)
self
.
validate
((
n
p
.
uint16
(
2
),
2
,
3
,
3
),
(
3
,
2
,
3
,
3
),
'valid'
,
verify_grad
=
False
)
self
.
validate
((
2
,
n
p
.
uint32
(
2
),
3
,
3
),
(
3
,
2
,
3
,
3
),
'valid'
,
verify_grad
=
False
)
def
test_uint_filter_shape_datatype
(
self
):
"""Tests for uint datatype in filter_shape
"""
self
.
validate
((
3
,
2
,
3
,
3
),
(
2
,
2
,
3
,
n
umpy
.
uint8
(
3
)),
'valid'
,
verify_grad
=
False
)
self
.
validate
((
3
,
2
,
3
,
3
),
(
n
umpy
.
uint16
(
2
),
2
,
3
,
3
),
'valid'
,
verify_grad
=
False
)
self
.
validate
((
3
,
2
,
3
,
3
),
(
2
,
n
umpy
.
uint32
(
2
),
3
,
3
),
'valid'
,
verify_grad
=
False
)
self
.
validate
((
3
,
2
,
3
,
3
),
(
2
,
2
,
3
,
n
p
.
uint8
(
3
)),
'valid'
,
verify_grad
=
False
)
self
.
validate
((
3
,
2
,
3
,
3
),
(
n
p
.
uint16
(
2
),
2
,
3
,
3
),
'valid'
,
verify_grad
=
False
)
self
.
validate
((
3
,
2
,
3
,
3
),
(
2
,
n
p
.
uint32
(
2
),
3
,
3
),
'valid'
,
verify_grad
=
False
)
def
test_img_kernel_same_shape
(
self
):
self
.
validate
((
3
,
2
,
3
,
3
),
(
4
,
2
,
3
,
3
),
'full'
)
...
...
@@ -474,8 +474,8 @@ class TestConv2D(utt.InferShapeTester):
print
(
"filter_shapes"
,
filter_shapes
)
for
filter_shape
in
filter_shapes
:
input
=
theano
.
shared
(
n
umpy
.
random
.
random
(
image_shape
))
filters
=
theano
.
shared
(
n
umpy
.
random
.
random
(
filter_shape
))
input
=
theano
.
shared
(
n
p
.
random
.
random
(
image_shape
))
filters
=
theano
.
shared
(
n
p
.
random
.
random
(
filter_shape
))
output
=
self
.
conv2d
(
input
,
filters
,
...
...
@@ -498,7 +498,7 @@ class TestConv2D(utt.InferShapeTester):
# must be provided explicitly
def
rand
(
*
shape
):
r
=
n
umpy
.
asarray
(
numpy
.
random
.
rand
(
*
shape
),
dtype
=
'float64'
)
r
=
n
p
.
asarray
(
np
.
random
.
rand
(
*
shape
),
dtype
=
'float64'
)
return
r
*
2
-
1
adtens
=
T
.
dtensor4
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论