Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
106eb11f
提交
106eb11f
authored
8月 11, 2017
作者:
affanv14
提交者:
Arnaud Bergeron
8月 18, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add tests for separable conv3d
上级
e11121cd
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
84 行增加
和
32 行删除
+84
-32
test_abstract_conv.py
theano/tensor/nnet/tests/test_abstract_conv.py
+84
-32
没有找到文件。
theano/tensor/nnet/tests/test_abstract_conv.py
浏览文件 @
106eb11f
...
@@ -23,7 +23,7 @@ from theano.tensor.nnet.abstract_conv import AbstractConv2d_gradWeights
...
@@ -23,7 +23,7 @@ from theano.tensor.nnet.abstract_conv import AbstractConv2d_gradWeights
from
theano.tensor.nnet.abstract_conv
import
bilinear_kernel_1D
from
theano.tensor.nnet.abstract_conv
import
bilinear_kernel_1D
from
theano.tensor.nnet.abstract_conv
import
bilinear_kernel_2D
from
theano.tensor.nnet.abstract_conv
import
bilinear_kernel_2D
from
theano.tensor.nnet.abstract_conv
import
bilinear_upsampling
from
theano.tensor.nnet.abstract_conv
import
bilinear_upsampling
from
theano.tensor.nnet.abstract_conv
import
separable_conv2d
from
theano.tensor.nnet.abstract_conv
import
separable_conv2d
,
separable_conv3d
from
theano.tensor.nnet.corr
import
(
CorrMM
,
CorrMM_gradWeights
,
from
theano.tensor.nnet.corr
import
(
CorrMM
,
CorrMM_gradWeights
,
CorrMM_gradInputs
)
CorrMM_gradInputs
)
from
theano.tensor.nnet.corr3d
import
(
Corr3dMM
,
Corr3dMM_gradWeights
,
from
theano.tensor.nnet.corr3d
import
(
Corr3dMM
,
Corr3dMM_gradWeights
,
...
@@ -1652,35 +1652,96 @@ class Grouped_conv3d_noOptim(Grouped_conv_noOptim):
...
@@ -1652,35 +1652,96 @@ class Grouped_conv3d_noOptim(Grouped_conv_noOptim):
class
Separable_conv
(
unittest
.
TestCase
):
class
Separable_conv
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
x
=
np
.
array
([[[[
1
,
2
,
3
,
4
,
5
],
[
3
,
2
,
1
,
4
,
5
],
[
3
,
3
,
1
,
3
,
6
],
[
5
,
3
,
2
,
1
,
1
],
[
4
,
7
,
1
,
2
,
1
]],
[[
3
,
3
,
1
,
2
,
6
],
[
6
,
5
,
4
,
3
,
1
],
[
3
,
4
,
5
,
2
,
3
],
[
6
,
4
,
1
,
3
,
4
],
[
2
,
3
,
4
,
2
,
5
]]]])
.
astype
(
theano
.
config
.
floatX
)
def
test_interface
(
self
):
self
.
depthwise_filter
=
np
.
array
([[[[
3
,
2
,
1
],
[
5
,
3
,
2
],
[
6
,
4
,
2
]]],
[[[
5
,
5
,
2
],
[
3
,
7
,
4
],
[
3
,
5
,
4
]]],
x
=
np
.
array
([[[[
1
,
2
,
3
,
4
,
5
],
[
3
,
2
,
1
,
4
,
5
],
[
3
,
3
,
1
,
3
,
6
],
[
5
,
3
,
2
,
1
,
1
],
[
4
,
7
,
1
,
2
,
1
]],
[[[
7
,
4
,
7
],
[
5
,
3
,
3
],
[
1
,
3
,
1
]]],
[[[
4
,
4
,
4
],
[
2
,
4
,
6
],
[
0
,
0
,
7
]]]])
.
astype
(
theano
.
config
.
floatX
)
[[
3
,
3
,
1
,
2
,
6
],
[
6
,
5
,
4
,
3
,
1
],
[
3
,
4
,
5
,
2
,
3
],
[
6
,
4
,
1
,
3
,
4
],
[
2
,
3
,
4
,
2
,
5
]]]])
.
astype
(
theano
.
config
.
floatX
)
self
.
pointwise_filter
=
np
.
array
([[[[
4
]],
[[
1
]],
[[
3
]],
[[
5
]]],
[[[
2
]],
[[
1
]],
[[
2
]],
[[
8
]]]])
.
astype
(
theano
.
config
.
floatX
)
depthwise_filter
=
np
.
array
([[[[
3
,
2
,
1
],
[
5
,
3
,
2
],
[
6
,
4
,
2
]]],
[[[
5
,
5
,
2
],
[
3
,
7
,
4
],
[
3
,
5
,
4
]
]],
self
.
precomp_output_valid
=
np
.
array
([[[[
1385
,
1333
,
1339
],
[
1382
,
1243
,
1291
],
[
1303
,
1120
,
1228
]],
[[[
7
,
4
,
7
],
[
5
,
3
,
3
],
[
1
,
3
,
1
]]],
[[[
4
,
4
,
4
],
[
2
,
4
,
6
],
[
0
,
0
,
7
]]]])
.
astype
(
theano
.
config
.
floatX
)
[[
1532
,
1410
,
1259
],
[
1522
,
1346
,
1314
],
[
1379
,
1192
,
1286
]]]])
.
astype
(
theano
.
config
.
floatX
)
pointwise_filter
=
np
.
array
([[[[
4
]],
[[
1
]],
[[
3
]],
[[
5
]]],
[[[
2
]],
[[
1
]],
[[
2
]],
[[
8
]]]])
.
astype
(
theano
.
config
.
floatX
)
self
.
precomp_output_full
=
np
.
array
([[[[
140
,
266
,
343
,
206
,
59
],
precomp_output
=
np
.
array
([[[[
1385
,
1333
,
1339
],
[
1382
,
1243
,
1291
],
[
1303
,
1120
,
1228
]],
[
395
,
697
,
979
,
585
,
245
],
[[
1532
,
1410
,
1259
],
[
1522
,
1346
,
1314
],
[
1379
,
1192
,
1286
]]]])
.
astype
(
theano
.
config
.
floatX
)
[
429
,
863
,
1385
,
919
,
453
],
[
243
,
499
,
864
,
627
,
371
],
[
90
,
183
,
291
,
254
,
202
]],
[[
149
,
289
,
359
,
213
,
58
],
[
400
,
750
,
1076
,
662
,
266
],
[
387
,
854
,
1532
,
1091
,
540
],
[
174
,
411
,
971
,
786
,
518
],
[
51
,
110
,
286
,
299
,
298
]]]])
.
astype
(
theano
.
config
.
floatX
)
def
test_interface2d
(
self
):
x_sym
=
theano
.
tensor
.
tensor4
(
'x'
)
x_sym
=
theano
.
tensor
.
tensor4
(
'x'
)
dfilter_sym
=
theano
.
tensor
.
tensor4
(
'd'
)
dfilter_sym
=
theano
.
tensor
.
tensor4
(
'd'
)
pfilter_sym
=
theano
.
tensor
.
tensor4
(
'p'
)
pfilter_sym
=
theano
.
tensor
.
tensor4
(
'p'
)
sep_op
=
separable_conv2d
(
x_sym
,
dfilter_sym
,
pfilter_sym
,
x
.
shape
[
1
])
sep_op
=
separable_conv2d
(
x_sym
,
dfilter_sym
,
pfilter_sym
,
self
.
x
.
shape
[
1
])
fun
=
theano
.
function
([
x_sym
,
dfilter_sym
,
pfilter_sym
],
sep_op
,
mode
=
'FAST_RUN'
)
fun
=
theano
.
function
([
x_sym
,
dfilter_sym
,
pfilter_sym
],
sep_op
,
mode
=
'FAST_RUN'
)
# test for square matrix
# test for square matrix
top
=
fun
(
x
,
depthwise_filter
,
pointwise_filter
)
top
=
fun
(
self
.
x
,
self
.
depthwise_filter
,
self
.
pointwise_filter
)
utt
.
assert_allclose
(
top
,
precomp_output
)
utt
.
assert_allclose
(
top
,
self
.
precomp_output_valid
)
# test for non-square matrix
# test for non-square matrix
top
=
fun
(
x
[:,
:,
:
3
,
:],
depthwise_filter
,
pointwise_filter
)
top
=
fun
(
self
.
x
[:,
:,
:
3
,
:],
self
.
depthwise_filter
,
self
.
pointwise_filter
)
utt
.
assert_allclose
(
top
,
precomp_output
[:,
:,
:
1
,
:])
utt
.
assert_allclose
(
top
,
self
.
precomp_output_valid
[:,
:,
:
1
,
:])
# test if it infers shape
# test if it infers shape
sep_op
=
separable_conv2d
(
x_sym
,
sep_op
=
separable_conv2d
(
x_sym
,
dfilter_sym
,
pfilter_sym
,
self
.
x
.
shape
[
1
],
input_shape
=
self
.
x
.
shape
,
depthwise_filter_shape
=
self
.
depthwise_filter
.
shape
,
pointwise_filter_shape
=
self
.
pointwise_filter
.
shape
)
fun
=
theano
.
function
([
x_sym
,
dfilter_sym
,
pfilter_sym
],
sep_op
,
mode
=
'FAST_RUN'
)
top
=
fun
(
self
.
x
,
self
.
depthwise_filter
,
self
.
pointwise_filter
)
utt
.
assert_allclose
(
top
,
self
.
precomp_output_valid
)
# test non-default subsample
sep_op
=
separable_conv2d
(
x_sym
,
dfilter_sym
,
pfilter_sym
,
self
.
x
.
shape
[
1
],
subsample
=
(
2
,
2
))
fun
=
theano
.
function
([
x_sym
,
dfilter_sym
,
pfilter_sym
],
sep_op
,
mode
=
'FAST_RUN'
)
top
=
fun
(
self
.
x
,
self
.
depthwise_filter
,
self
.
pointwise_filter
)
utt
.
assert_allclose
(
top
,
np
.
delete
(
np
.
delete
(
self
.
precomp_output_valid
,
1
,
axis
=
3
),
1
,
axis
=
2
))
# test non-default border_mode
sep_op
=
separable_conv2d
(
x_sym
,
dfilter_sym
,
pfilter_sym
,
self
.
x
.
shape
[
1
],
border_mode
=
'full'
)
fun
=
theano
.
function
([
x_sym
,
dfilter_sym
,
pfilter_sym
],
sep_op
,
mode
=
'FAST_RUN'
)
top
=
fun
(
self
.
x
[:,
:,
:
3
,
:
3
],
self
.
depthwise_filter
,
self
.
pointwise_filter
)
utt
.
assert_allclose
(
top
,
self
.
precomp_output_full
)
def
test_interface3d
(
self
):
# Expand the filter along the depth
x
=
np
.
tile
(
np
.
expand_dims
(
self
.
x
,
axis
=
2
),
(
1
,
1
,
5
,
1
,
1
))
depthwise_filter
=
np
.
tile
(
np
.
expand_dims
(
self
.
depthwise_filter
,
axis
=
2
),
(
1
,
1
,
3
,
1
,
1
))
pointwise_filter
=
np
.
expand_dims
(
self
.
pointwise_filter
,
axis
=
2
)
precomp_output
=
np
.
tile
(
np
.
expand_dims
(
self
.
precomp_output_valid
,
axis
=
2
),
(
1
,
1
,
3
,
1
,
1
))
*
3
x_sym
=
theano
.
tensor
.
tensor5
(
'x'
)
dfilter_sym
=
theano
.
tensor
.
tensor5
(
'd'
)
pfilter_sym
=
theano
.
tensor
.
tensor5
(
'p'
)
sep_op
=
separable_conv3d
(
x_sym
,
dfilter_sym
,
pfilter_sym
,
x
.
shape
[
1
])
fun
=
theano
.
function
([
x_sym
,
dfilter_sym
,
pfilter_sym
],
sep_op
,
mode
=
'FAST_RUN'
)
# test for square matrix
top
=
fun
(
x
,
depthwise_filter
,
pointwise_filter
)
utt
.
assert_allclose
(
top
,
precomp_output
)
# test for non-square matrix
top
=
fun
(
x
[:,
:,
:
3
,
:,
:
3
],
depthwise_filter
,
pointwise_filter
)
utt
.
assert_allclose
(
top
,
precomp_output
[:,
:,
:
1
,
:,
:
1
])
# test if it infers shape
sep_op
=
separable_conv3d
(
x_sym
,
dfilter_sym
,
dfilter_sym
,
pfilter_sym
,
pfilter_sym
,
x
.
shape
[
1
],
x
.
shape
[
1
],
...
@@ -1692,29 +1753,20 @@ class Separable_conv(unittest.TestCase):
...
@@ -1692,29 +1753,20 @@ class Separable_conv(unittest.TestCase):
utt
.
assert_allclose
(
top
,
precomp_output
)
utt
.
assert_allclose
(
top
,
precomp_output
)
# test non-default subsample
# test non-default subsample
sep_op
=
separable_conv
2
d
(
x_sym
,
sep_op
=
separable_conv
3
d
(
x_sym
,
dfilter_sym
,
dfilter_sym
,
pfilter_sym
,
pfilter_sym
,
x
.
shape
[
1
],
x
.
shape
[
1
],
subsample
=
(
2
,
2
))
subsample
=
(
2
,
2
,
2
))
fun
=
theano
.
function
([
x_sym
,
dfilter_sym
,
pfilter_sym
],
sep_op
,
mode
=
'FAST_RUN'
)
fun
=
theano
.
function
([
x_sym
,
dfilter_sym
,
pfilter_sym
],
sep_op
,
mode
=
'FAST_RUN'
)
top
=
fun
(
x
,
depthwise_filter
,
pointwise_filter
)
top
=
fun
(
x
,
depthwise_filter
,
pointwise_filter
)
utt
.
assert_allclose
(
top
,
np
.
delete
(
np
.
delete
(
precomp_output
,
1
,
axis
=
3
),
1
,
axis
=
2
))
utt
.
assert_allclose
(
top
,
np
.
delete
(
np
.
delete
(
np
.
delete
(
precomp_output
,
1
,
axis
=
4
),
1
,
axis
=
3
),
1
,
axis
=
2
))
# test non-default border_mode
# test non-default border_mode
precomp_output
=
np
.
array
([[[[
140
,
266
,
343
,
206
,
59
],
precomp_output
=
np
.
tile
(
np
.
expand_dims
(
self
.
precomp_output_full
,
axis
=
2
),
[
395
,
697
,
979
,
585
,
245
],
(
1
,
1
,
5
,
1
,
1
))
*
np
.
array
([[[[[
1
]],
[[
2
]],
[[
3
]],
[[
2
]],
[[
1
]]]]])
[
429
,
863
,
1385
,
919
,
453
],
[
243
,
499
,
864
,
627
,
371
],
sep_op
=
separable_conv3d
(
x_sym
,
dfilter_sym
,
pfilter_sym
,
x
.
shape
[
1
],
border_mode
=
'full'
)
[
90
,
183
,
291
,
254
,
202
]],
[[
149
,
289
,
359
,
213
,
58
],
[
400
,
750
,
1076
,
662
,
266
],
[
387
,
854
,
1532
,
1091
,
540
],
[
174
,
411
,
971
,
786
,
518
],
[
51
,
110
,
286
,
299
,
298
]]]])
.
astype
(
theano
.
config
.
floatX
)
sep_op
=
separable_conv2d
(
x_sym
,
dfilter_sym
,
pfilter_sym
,
x
.
shape
[
1
],
border_mode
=
'full'
)
fun
=
theano
.
function
([
x_sym
,
dfilter_sym
,
pfilter_sym
],
sep_op
,
mode
=
'FAST_RUN'
)
fun
=
theano
.
function
([
x_sym
,
dfilter_sym
,
pfilter_sym
],
sep_op
,
mode
=
'FAST_RUN'
)
top
=
fun
(
x
[:,
:,
:
3
,
:
3
],
depthwise_filter
,
pointwise_filter
)
top
=
fun
(
x
[:,
:,
:
3
,
:
3
,
:
3
],
depthwise_filter
,
pointwise_filter
)
utt
.
assert_allclose
(
top
,
precomp_output
)
utt
.
assert_allclose
(
top
,
precomp_output
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论