Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0c57414e
提交
0c57414e
authored
7月 08, 2016
作者:
Frédéric Bastien
提交者:
GitHub
7月 08, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4654 from slefrancois/yield_test_absconv
yield test in test_abstract_conv for tensor.nnet, sandbox.cuda and gpuarray
上级
9556ea38
3cabbcd9
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
48 行增加
和
53 行删除
+48
-53
test_abstractconv.py
theano/gpuarray/tests/test_abstractconv.py
+5
-4
test_abstractconv.py
theano/sandbox/cuda/tests/test_abstractconv.py
+10
-8
test_abstract_conv.py
theano/tensor/nnet/tests/test_abstract_conv.py
+33
-41
没有找到文件。
theano/gpuarray/tests/test_abstractconv.py
浏览文件 @
0c57414e
...
@@ -15,11 +15,12 @@ gpu_ftensor4 = GpuArrayType(dtype='float32', broadcastable=(False,) * 4)
...
@@ -15,11 +15,12 @@ gpu_ftensor4 = GpuArrayType(dtype='float32', broadcastable=(False,) * 4)
class
TestDnnConv2d
(
test_abstract_conv
.
BaseTestConv2d
):
class
TestDnnConv2d
(
test_abstract_conv
.
BaseTestConv2d
):
def
setUp
(
self
):
@classmethod
super
(
TestDnnConv2d
,
self
)
.
setUp
()
def
setup_class
(
cls
):
self
.
shared
=
gpuarray_shared_constructor
test_abstract_conv
.
BaseTestConv2d
.
setup_class
()
cls
.
shared
=
staticmethod
(
gpuarray_shared_constructor
)
# provide_shape is not used by the cuDNN impementation
# provide_shape is not used by the cuDNN impementation
self
.
provide_shape
=
[
False
]
cls
.
provide_shape
=
[
False
]
def
tcase
(
self
,
i
,
f
,
s
,
b
,
flip
,
provide_shape
,
fd
=
(
1
,
1
)):
def
tcase
(
self
,
i
,
f
,
s
,
b
,
flip
,
provide_shape
,
fd
=
(
1
,
1
)):
if
not
dnn_available
(
test_ctx_name
):
if
not
dnn_available
(
test_ctx_name
):
...
...
theano/sandbox/cuda/tests/test_abstractconv.py
浏览文件 @
0c57414e
...
@@ -23,11 +23,12 @@ else:
...
@@ -23,11 +23,12 @@ else:
class
TestDnnConv2d
(
test_abstract_conv
.
BaseTestConv2d
):
class
TestDnnConv2d
(
test_abstract_conv
.
BaseTestConv2d
):
def
setUp
(
self
):
@classmethod
super
(
TestDnnConv2d
,
self
)
.
setUp
()
def
setup_class
(
cls
):
test_abstract_conv
.
BaseTestConv2d
.
setup_class
()
# provide_shape is not used by the cuDNN impementation
# provide_shape is not used by the cuDNN impementation
self
.
provide_shape
=
[
False
]
cls
.
provide_shape
=
[
False
]
self
.
shared
=
gpu_shared
cls
.
shared
=
staticmethod
(
gpu_shared
)
def
tcase
(
self
,
i
,
f
,
s
,
b
,
flip
,
provide_shape
,
fd
=
(
1
,
1
)):
def
tcase
(
self
,
i
,
f
,
s
,
b
,
flip
,
provide_shape
,
fd
=
(
1
,
1
)):
if
fd
!=
(
1
,
1
):
if
fd
!=
(
1
,
1
):
...
@@ -56,10 +57,11 @@ class TestDnnConv2d(test_abstract_conv.BaseTestConv2d):
...
@@ -56,10 +57,11 @@ class TestDnnConv2d(test_abstract_conv.BaseTestConv2d):
class
TestCorrMMConv2d
(
test_abstract_conv
.
BaseTestConv2d
):
class
TestCorrMMConv2d
(
test_abstract_conv
.
BaseTestConv2d
):
def
setUp
(
self
):
@classmethod
super
(
TestCorrMMConv2d
,
self
)
.
setUp
()
def
setup_class
(
cls
):
self
.
shared
=
gpu_shared
test_abstract_conv
.
BaseTestConv2d
.
setup_class
()
self
.
mode
=
mode_with_gpu
.
excluding
(
'cudnn'
)
cls
.
shared
=
staticmethod
(
gpu_shared
)
cls
.
mode
=
mode_with_gpu
.
excluding
(
'cudnn'
)
def
tcase
(
self
,
i
,
f
,
s
,
b
,
flip
,
provide_shape
,
fd
=
(
1
,
1
)):
def
tcase
(
self
,
i
,
f
,
s
,
b
,
flip
,
provide_shape
,
fd
=
(
1
,
1
)):
mode
=
self
.
mode
mode
=
self
.
mode
...
...
theano/tensor/nnet/tests/test_abstract_conv.py
浏览文件 @
0c57414e
...
@@ -3,7 +3,8 @@ import unittest
...
@@ -3,7 +3,8 @@ import unittest
import
numpy
import
numpy
import
numpy
as
np
import
numpy
as
np
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
from
nose.tools
import
assert_raises
from
nose.tools
import
assert_raises
,
assert_true
import
theano
import
theano
from
theano
import
tensor
from
theano
import
tensor
from
theano.gof.opt
import
check_stack_trace
from
theano.gof.opt
import
check_stack_trace
...
@@ -77,20 +78,21 @@ class TestGetConvOutShape(unittest.TestCase):
...
@@ -77,20 +78,21 @@ class TestGetConvOutShape(unittest.TestCase):
self
.
assertTrue
(
test4_params
==
(
3
,
4
,
6
,
4
))
self
.
assertTrue
(
test4_params
==
(
3
,
4
,
6
,
4
))
class
BaseTestConv2d
(
unittest
.
TestCase
):
class
BaseTestConv2d
:
def
setUp
(
self
):
@classmethod
def
setup_class
(
cls
):
if
theano
.
config
.
blas
.
ldflags
==
''
:
if
theano
.
config
.
blas
.
ldflags
==
''
:
raise
SkipTest
(
"BLAS required for reference"
)
raise
SkipTest
(
"BLAS required for reference"
)
self
.
inputs_shapes
=
[(
8
,
1
,
6
,
6
),
(
8
,
1
,
8
,
8
),
(
2
,
1
,
7
,
7
),
cls
.
inputs_shapes
=
[(
8
,
1
,
6
,
6
),
(
8
,
1
,
8
,
8
),
(
2
,
1
,
7
,
7
),
(
6
,
1
,
10
,
11
),
(
2
,
1
,
6
,
5
),
(
1
,
5
,
9
,
9
)]
(
6
,
1
,
10
,
11
),
(
2
,
1
,
6
,
5
),
(
1
,
5
,
9
,
9
)]
self
.
filters_shapes
=
[(
5
,
1
,
2
,
2
),
(
4
,
1
,
3
,
3
),
(
2
,
1
,
3
,
3
),
cls
.
filters_shapes
=
[(
5
,
1
,
2
,
2
),
(
4
,
1
,
3
,
3
),
(
2
,
1
,
3
,
3
),
(
1
,
1
,
2
,
3
),
(
4
,
1
,
1
,
3
),
(
4
,
5
,
3
,
2
)]
(
1
,
1
,
2
,
3
),
(
4
,
1
,
1
,
3
),
(
4
,
5
,
3
,
2
)]
self
.
subsamples
=
[(
1
,
1
),
(
2
,
2
),
(
2
,
4
)]
cls
.
subsamples
=
[(
1
,
1
),
(
2
,
2
),
(
2
,
4
)]
self
.
filters_dilations
=
[(
1
,
1
),
(
1
,
2
),
(
2
,
1
)]
cls
.
filters_dilations
=
[(
1
,
1
),
(
1
,
2
),
(
2
,
1
)]
self
.
border_modes
=
[
"valid"
,
"full"
,
(
0
,
0
),
(
1
,
1
),
(
5
,
5
),
(
5
,
2
)]
cls
.
border_modes
=
[
"valid"
,
"full"
,
(
0
,
0
),
(
1
,
1
),
(
5
,
5
),
(
5
,
2
)]
self
.
filter_flip
=
[
True
,
False
]
cls
.
filter_flip
=
[
True
,
False
]
self
.
provide_shape
=
[
True
,
False
]
cls
.
provide_shape
=
[
True
,
False
]
self
.
shared
=
theano
.
compile
.
shared
cls
.
shared
=
staticmethod
(
theano
.
compile
.
shared
)
def
get_output_shape
(
self
,
inputs_shape
,
filters_shape
,
def
get_output_shape
(
self
,
inputs_shape
,
filters_shape
,
subsample
,
border_mode
,
filter_dilation
):
subsample
,
border_mode
,
filter_dilation
):
...
@@ -153,7 +155,7 @@ class BaseTestConv2d(unittest.TestCase):
...
@@ -153,7 +155,7 @@ class BaseTestConv2d(unittest.TestCase):
assert
any
([
isinstance
(
n
.
op
,
target_op
)
for
n
assert
any
([
isinstance
(
n
.
op
,
target_op
)
for
n
in
f
.
maker
.
fgraph
.
toposort
()])
in
f
.
maker
.
fgraph
.
toposort
()])
if
check_trace
:
if
check_trace
:
self
.
assertT
rue
(
check_stack_trace
(
f
,
ops_to_check
=
target_op
))
assert_t
rue
(
check_stack_trace
(
f
,
ops_to_check
=
target_op
))
res_ref
=
numpy
.
array
(
f_ref
())
res_ref
=
numpy
.
array
(
f_ref
())
res
=
numpy
.
array
(
f
())
res
=
numpy
.
array
(
f
())
...
@@ -207,7 +209,7 @@ class BaseTestConv2d(unittest.TestCase):
...
@@ -207,7 +209,7 @@ class BaseTestConv2d(unittest.TestCase):
assert
any
([
isinstance
(
n
.
op
,
target_op
)
for
n
assert
any
([
isinstance
(
n
.
op
,
target_op
)
for
n
in
f
.
maker
.
fgraph
.
toposort
()])
in
f
.
maker
.
fgraph
.
toposort
()])
if
check_trace
:
if
check_trace
:
self
.
assertT
rue
(
check_stack_trace
(
f
,
ops_to_check
=
target_op
))
assert_t
rue
(
check_stack_trace
(
f
,
ops_to_check
=
target_op
))
res_ref
=
numpy
.
array
(
f_ref
())
res_ref
=
numpy
.
array
(
f_ref
())
res
=
numpy
.
array
(
f
())
res
=
numpy
.
array
(
f
())
...
@@ -260,7 +262,7 @@ class BaseTestConv2d(unittest.TestCase):
...
@@ -260,7 +262,7 @@ class BaseTestConv2d(unittest.TestCase):
assert
any
([
isinstance
(
n
.
op
,
target_op
)
for
n
assert
any
([
isinstance
(
n
.
op
,
target_op
)
for
n
in
f
.
maker
.
fgraph
.
toposort
()])
in
f
.
maker
.
fgraph
.
toposort
()])
if
check_trace
:
if
check_trace
:
self
.
assertT
rue
(
check_stack_trace
(
f
,
ops_to_check
=
target_op
))
assert_t
rue
(
check_stack_trace
(
f
,
ops_to_check
=
target_op
))
res_ref
=
numpy
.
array
(
f_ref
())
res_ref
=
numpy
.
array
(
f_ref
())
res
=
numpy
.
array
(
f
())
res
=
numpy
.
array
(
f
())
...
@@ -284,36 +286,24 @@ class BaseTestConv2d(unittest.TestCase):
...
@@ -284,36 +286,24 @@ class BaseTestConv2d(unittest.TestCase):
db
=
(
0
,
0
)
db
=
(
0
,
0
)
dflip
=
True
in
self
.
filter_flip
dflip
=
True
in
self
.
filter_flip
dprovide_shape
=
True
in
self
.
provide_shape
dprovide_shape
=
True
in
self
.
provide_shape
skipped
=
False
for
(
i
,
f
)
in
zip
(
self
.
inputs_shapes
,
self
.
filters_shapes
):
for
(
i
,
f
)
in
zip
(
self
.
inputs_shapes
,
self
.
filters_shapes
):
for
provide_shape
in
self
.
provide_shape
:
for
provide_shape
in
self
.
provide_shape
:
try
:
yield
(
self
.
tcase
,
i
,
f
,
ds
,
db
,
dflip
,
provide_shape
)
self
.
tcase
(
i
,
f
,
ds
,
db
,
dflip
,
provide_shape
)
except
SkipTest
as
e
:
skipped
=
e
for
fd
in
self
.
filters_dilations
:
for
fd
in
self
.
filters_dilations
:
for
s
in
self
.
subsamples
:
for
s
in
self
.
subsamples
:
for
b
in
self
.
border_modes
:
for
b
in
self
.
border_modes
:
try
:
yield
(
self
.
tcase
,
i
,
f
,
s
,
db
,
dflip
,
self
.
tcase
(
i
,
f
,
s
,
db
,
dflip
,
dprovide_shape
,
fd
)
dprovide_shape
,
fd
)
except
SkipTest
as
e
:
skipped
=
e
for
flip
in
self
.
filter_flip
:
for
flip
in
self
.
filter_flip
:
try
:
yield
(
self
.
tcase
,
i
,
f
,
ds
,
db
,
flip
,
dprovide_shape
)
self
.
tcase
(
i
,
f
,
ds
,
db
,
flip
,
dprovide_shape
)
except
SkipTest
as
e
:
skipped
=
e
if
skipped
:
raise
skipped
class
TestCorrConv2d
(
BaseTestConv2d
):
class
TestCorrConv2d
(
BaseTestConv2d
):
def
setUp
(
self
):
@classmethod
def
setup_class
(
cls
):
if
theano
.
config
.
blas
.
ldflags
==
""
:
if
theano
.
config
.
blas
.
ldflags
==
""
:
raise
SkipTest
()
raise
SkipTest
()
return
super
(
TestCorrConv2d
,
self
)
.
setUp
()
BaseTestConv2d
.
setup_class
()
def
tcase
(
self
,
i
,
f
,
s
,
b
,
flip
,
provide_shape
,
fd
=
(
1
,
1
)):
def
tcase
(
self
,
i
,
f
,
s
,
b
,
flip
,
provide_shape
,
fd
=
(
1
,
1
)):
o
=
self
.
get_output_shape
(
i
,
f
,
s
,
b
,
fd
)
o
=
self
.
get_output_shape
(
i
,
f
,
s
,
b
,
fd
)
...
@@ -339,14 +329,16 @@ class TestCorrConv2d(BaseTestConv2d):
...
@@ -339,14 +329,16 @@ class TestCorrConv2d(BaseTestConv2d):
class
TestCpuConv2d
(
BaseTestConv2d
):
class
TestCpuConv2d
(
BaseTestConv2d
):
def
setUp
(
self
):
@classmethod
super
(
TestCpuConv2d
,
self
)
.
setUp
()
def
setup
(
cls
):
self
.
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
.
excluding
(
'conv_gemm'
)
BaseTestConv2d
.
setup_class
()
self
.
opt_err
=
theano
.
config
.
on_opt_error
cls
.
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
.
excluding
(
'conv_gemm'
)
cls
.
opt_err
=
theano
.
config
.
on_opt_error
theano
.
config
.
on_opt_error
=
'ignore'
theano
.
config
.
on_opt_error
=
'ignore'
def
tearDown
(
self
):
@classmethod
theano
.
config
.
on_opt_error
=
self
.
opt_err
def
tearDown
(
cls
):
theano
.
config
.
on_opt_error
=
cls
.
opt_err
def
tcase
(
self
,
i
,
f
,
s
,
b
,
flip
,
provide_shape
,
fd
=
(
1
,
1
)):
def
tcase
(
self
,
i
,
f
,
s
,
b
,
flip
,
provide_shape
,
fd
=
(
1
,
1
)):
if
fd
!=
(
1
,
1
):
if
fd
!=
(
1
,
1
):
...
@@ -385,7 +377,7 @@ class TestCpuConv2d(BaseTestConv2d):
...
@@ -385,7 +377,7 @@ class TestCpuConv2d(BaseTestConv2d):
check_trace
=
True
,
filter_dilation
=
fd
)
check_trace
=
True
,
filter_dilation
=
fd
)
else
:
else
:
self
.
assertR
aises
(
AssertionError
,
assert_r
aises
(
AssertionError
,
self
.
run_fwd
,
self
.
run_fwd
,
inputs_shape
=
i
,
inputs_shape
=
i
,
filters_shape
=
f
,
filters_shape
=
f
,
...
@@ -410,7 +402,7 @@ class TestCpuConv2d(BaseTestConv2d):
...
@@ -410,7 +402,7 @@ class TestCpuConv2d(BaseTestConv2d):
check_trace
=
True
,
check_trace
=
True
,
filter_dilation
=
fd
)
filter_dilation
=
fd
)
else
:
else
:
self
.
assertR
aises
(
AssertionError
,
assert_r
aises
(
AssertionError
,
self
.
run_gradweight
,
self
.
run_gradweight
,
inputs_shape
=
i
,
inputs_shape
=
i
,
filters_shape
=
f
,
filters_shape
=
f
,
...
@@ -436,7 +428,7 @@ class TestCpuConv2d(BaseTestConv2d):
...
@@ -436,7 +428,7 @@ class TestCpuConv2d(BaseTestConv2d):
check_trace
=
True
,
check_trace
=
True
,
filter_dilation
=
fd
)
filter_dilation
=
fd
)
else
:
else
:
self
.
assertR
aises
(
AssertionError
,
assert_r
aises
(
AssertionError
,
self
.
run_gradinput
,
self
.
run_gradinput
,
inputs_shape
=
i
,
inputs_shape
=
i
,
filters_shape
=
f
,
filters_shape
=
f
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论