Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3e1be8a4
提交
3e1be8a4
authored
6月 05, 2017
作者:
affanv14
提交者:
Mohammed Affan
6月 14, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify corrmm tests for grouped convolution
上级
e44ce417
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
6 行增加
和
86 行删除
+6
-86
test_corr.py
theano/tensor/nnet/tests/test_corr.py
+6
-86
没有找到文件。
theano/tensor/nnet/tests/test_corr.py
浏览文件 @
3e1be8a4
...
@@ -5,12 +5,12 @@ from nose.plugins.attrib import attr
...
@@ -5,12 +5,12 @@ from nose.plugins.attrib import attr
from
nose.tools
import
assert_equals
from
nose.tools
import
assert_equals
import
numpy
as
np
import
numpy
as
np
from
six
import
integer_types
from
six
import
integer_types
import
unittest
import
theano
import
theano
import
theano.tensor
as
T
import
theano.tensor
as
T
from
theano.tests
import
unittest_tools
as
utt
from
theano.tests
import
unittest_tools
as
utt
from
theano.tensor.nnet
import
corr
,
conv
from
theano.tensor.nnet
import
corr
,
conv
from
theano.tensor.nnet.tests.test_abstract_conv
import
Grouped_conv_noOptim
class
TestCorr2D
(
utt
.
InferShapeTester
):
class
TestCorr2D
(
utt
.
InferShapeTester
):
...
@@ -417,95 +417,15 @@ class TestCorr2D(utt.InferShapeTester):
...
@@ -417,95 +417,15 @@ class TestCorr2D(utt.InferShapeTester):
self
.
validate
((
3
,
2
,
7
,
5
),
(
5
,
2
,
2
,
3
),
2
,
non_contiguous
=
True
)
self
.
validate
((
3
,
2
,
7
,
5
),
(
5
,
2
,
2
,
3
),
2
,
non_contiguous
=
True
)
class
TestGroupCorr2d
(
unittest
.
TestCase
):
class
TestGroupCorr2d
(
Grouped_conv_noOptim
):
if
theano
.
config
.
mode
==
"FAST_COMPILE"
:
if
theano
.
config
.
mode
==
"FAST_COMPILE"
:
mode
=
theano
.
compile
.
get_mode
(
"FAST_RUN"
)
mode
=
theano
.
compile
.
get_mode
(
"FAST_RUN"
)
else
:
else
:
mode
=
None
mode
=
None
conv2d
=
staticmethod
(
corr
.
CorrMM
)
def
setUp
(
self
):
conv2d_gradw
=
staticmethod
(
corr
.
CorrMM_gradWeights
)
self
.
img_shape
=
[(
5
,
6
,
5
,
5
),
(
4
,
4
,
7
,
5
),
(
3
,
8
,
5
,
3
),
(
2
,
4
,
7
,
7
)]
conv2d_gradi
=
staticmethod
(
corr
.
CorrMM_gradInputs
)
self
.
kern_shape
=
[(
6
,
2
,
3
,
3
),
(
6
,
2
,
5
,
3
),
(
4
,
2
,
3
,
3
),
(
4
,
1
,
3
,
5
)]
flip_filter
=
True
self
.
top_shape
=
[(
5
,
6
,
3
,
3
),
(
4
,
6
,
3
,
3
),
(
3
,
4
,
3
,
1
),
(
2
,
4
,
5
,
3
)]
self
.
num_groups
=
[
3
,
2
,
4
,
4
]
self
.
subsample
=
(
1
,
1
)
self
.
filter_dilation
=
(
1
,
1
)
self
.
border_mode
=
'valid'
self
.
ref_mode
=
theano
.
Mode
(
optimizer
=
None
)
def
test_fwd
(
self
):
for
imshp
,
kshp
,
groups
in
zip
(
self
.
img_shape
,
self
.
kern_shape
,
self
.
num_groups
):
img
=
np
.
random
.
random
(
imshp
)
kern
=
np
.
random
.
random
(
kshp
)
img_sym
=
T
.
tensor4
(
'img'
)
kern_sym
=
T
.
tensor4
(
'kern'
)
top_corr_sym
=
corr
.
CorrMM
(
self
.
border_mode
,
self
.
subsample
,
self
.
filter_dilation
,
groups
)(
img_sym
,
kern_sym
[:,
:,
::
-
1
,
::
-
1
])
corr_func
=
theano
.
function
([
img_sym
,
kern_sym
],
top_corr_sym
,
mode
=
self
.
mode
)
top_ref_sym
=
theano
.
tensor
.
nnet
.
conv2d
(
img_sym
,
kern_sym
,
border_mode
=
self
.
border_mode
,
subsample
=
self
.
subsample
,
filter_dilation
=
self
.
filter_dilation
,
num_groups
=
groups
)
ref_func
=
theano
.
function
([
img_sym
,
kern_sym
],
top_ref_sym
,
mode
=
self
.
ref_mode
)
top_corr
=
corr_func
(
img
,
kern
)
top_ref
=
ref_func
(
img
,
kern
)
utt
.
assert_allclose
(
top_corr
,
top_ref
)
def
test_gradW
(
self
):
for
imshp
,
tshp
,
kshp
,
groups
in
zip
(
self
.
img_shape
,
self
.
top_shape
,
self
.
kern_shape
,
self
.
num_groups
):
img
=
np
.
random
.
random
(
imshp
)
top
=
np
.
random
.
random
(
tshp
)
img_sym
=
T
.
tensor4
(
'img'
)
top_sym
=
T
.
tensor4
(
'top'
)
kern_corr_sym
=
corr
.
CorrMM_gradWeights
(
self
.
border_mode
,
self
.
subsample
,
self
.
filter_dilation
,
groups
)(
img_sym
,
top_sym
)
kern_corr_sym
=
kern_corr_sym
[:,
:,
::
-
1
,
::
-
1
]
corr_gradw_func
=
theano
.
function
([
img_sym
,
top_sym
],
kern_corr_sym
,
mode
=
self
.
mode
)
kern_ref_sym
=
theano
.
tensor
.
nnet
.
abstract_conv
.
AbstractConv2d_gradWeights
(
imshp
=
None
,
kshp
=
None
,
border_mode
=
self
.
border_mode
,
subsample
=
self
.
subsample
,
filter_dilation
=
self
.
filter_dilation
,
num_groups
=
groups
)(
img_sym
,
top_sym
,
kshp
[
-
2
:])
ref_gradw_func
=
theano
.
function
([
img_sym
,
top_sym
],
kern_ref_sym
,
mode
=
self
.
ref_mode
)
kern_corr
=
corr_gradw_func
(
img
,
top
)
kern_ref
=
ref_gradw_func
(
img
,
top
)
utt
.
assert_allclose
(
kern_corr
,
kern_ref
)
def
test_gradI
(
self
):
for
imshp
,
tshp
,
kshp
,
groups
in
zip
(
self
.
img_shape
,
self
.
top_shape
,
self
.
kern_shape
,
self
.
num_groups
):
kern
=
np
.
random
.
random
(
kshp
)
top
=
np
.
random
.
random
(
tshp
)
kern_sym
=
T
.
tensor4
(
'kern'
)
top_sym
=
T
.
tensor4
(
'top'
)
img_corr_sym
=
corr
.
CorrMM_gradInputs
(
self
.
border_mode
,
self
.
subsample
,
self
.
filter_dilation
,
groups
)(
kern_sym
[:,
:,
::
-
1
,
::
-
1
],
top_sym
)
corr_gradi_func
=
theano
.
function
([
kern_sym
,
top_sym
],
img_corr_sym
,
mode
=
self
.
mode
)
img_ref_sym
=
theano
.
tensor
.
nnet
.
abstract_conv
.
AbstractConv2d_gradInputs
(
imshp
=
None
,
kshp
=
None
,
border_mode
=
self
.
border_mode
,
subsample
=
self
.
subsample
,
filter_dilation
=
self
.
filter_dilation
,
num_groups
=
groups
)(
kern_sym
,
top_sym
,
imshp
[
-
2
:])
ref_gradi_func
=
theano
.
function
([
kern_sym
,
top_sym
],
img_ref_sym
,
mode
=
self
.
ref_mode
)
img_corr
=
corr_gradi_func
(
kern
,
top
)
img_ref
=
ref_gradi_func
(
kern
,
top
)
utt
.
assert_allclose
(
img_corr
,
img_ref
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论