Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
34a45383
提交
34a45383
authored
10月 09, 2014
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2164 from nouiz/tests
Fix buildbot errors.
上级
a14c3e9b
e46d75d2
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
33 行增加
和
29 行删除
+33
-29
test_types.py
theano/gof/tests/test_types.py
+4
-1
test_gemmcorr3d.py
theano/sandbox/cuda/tests/test_gemmcorr3d.py
+25
-25
test_opt.py
theano/tensor/tests/test_opt.py
+4
-3
没有找到文件。
theano/gof/tests/test_types.py
浏览文件 @
34a45383
...
@@ -64,9 +64,12 @@ def test_cdata():
...
@@ -64,9 +64,12 @@ def test_cdata():
i
=
TensorType
(
'float32'
,
(
False
,))()
i
=
TensorType
(
'float32'
,
(
False
,))()
c
=
ProdOp
()(
i
)
c
=
ProdOp
()(
i
)
i2
=
GetOp
()(
c
)
i2
=
GetOp
()(
c
)
mode
=
None
if
theano
.
config
.
mode
==
"FAST_COMPILE"
:
mode
=
"FAST_RUN"
# This should be a passthrough function for vectors
# This should be a passthrough function for vectors
f
=
theano
.
function
([
i
],
i2
)
f
=
theano
.
function
([
i
],
i2
,
mode
=
mode
)
v
=
numpy
.
random
.
randn
(
9
)
.
astype
(
'float32'
)
v
=
numpy
.
random
.
randn
(
9
)
.
astype
(
'float32'
)
...
...
theano/sandbox/cuda/tests/test_gemmcorr3d.py
浏览文件 @
34a45383
...
@@ -10,7 +10,8 @@ import theano.sandbox.cuda as cuda_ndarray
...
@@ -10,7 +10,8 @@ import theano.sandbox.cuda as cuda_ndarray
if
not
cuda_ndarray
.
cuda_available
:
if
not
cuda_ndarray
.
cuda_available
:
raise
SkipTest
(
'Optional package cuda not available'
)
raise
SkipTest
(
'Optional package cuda not available'
)
from
theano.sandbox.cuda
import
float32_shared_constructor
as
shared
from
theano.sandbox.cuda
import
float32_shared_constructor
as
shared
from
theano.sandbox.cuda.blas
import
GpuCorr3dMM
,
GpuCorr3dMM_gradWeights
,
GpuCorr3dMM_gradInputs
from
theano.sandbox.cuda.blas
import
(
GpuCorr3dMM
,
GpuCorr3dMM_gradWeights
,
GpuCorr3dMM_gradInputs
)
from
theano.sandbox.cuda.basic_ops
import
gpu_contiguous
from
theano.sandbox.cuda.basic_ops
import
gpu_contiguous
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
...
@@ -31,9 +32,10 @@ class TestCorr3DMM(unittest.TestCase):
...
@@ -31,9 +32,10 @@ class TestCorr3DMM(unittest.TestCase):
bias
=
shared
(
numpy
.
zeros
(
filters_shape
[
0
])
.
astype
(
'float32'
))
bias
=
shared
(
numpy
.
zeros
(
filters_shape
[
0
])
.
astype
(
'float32'
))
conv_ref
=
theano
.
tensor
.
nnet
.
conv3D
(
V
=
inputs
,
W
=
filters
,
conv_ref
=
theano
.
tensor
.
nnet
.
conv3D
(
V
=
inputs
,
W
=
filters
,
b
=
bias
,
d
=
subsample
)
b
=
bias
,
d
=
subsample
)
conv
=
GpuCorr3dMM
(
border_mode
=
"valid"
,
conv
=
GpuCorr3dMM
(
border_mode
=
"valid"
,
subsample
=
subsample
)(
inputs
.
dimshuffle
(
0
,
4
,
1
,
2
,
3
),
subsample
=
subsample
)(
filters
.
dimshuffle
(
0
,
4
,
1
,
2
,
3
))
inputs
.
dimshuffle
(
0
,
4
,
1
,
2
,
3
),
filters
.
dimshuffle
(
0
,
4
,
1
,
2
,
3
))
conv
=
conv
.
dimshuffle
(
0
,
2
,
3
,
4
,
1
)
conv
=
conv
.
dimshuffle
(
0
,
2
,
3
,
4
,
1
)
f_ref
=
theano
.
function
([],
conv_ref
)
f_ref
=
theano
.
function
([],
conv_ref
)
...
@@ -66,27 +68,26 @@ class TestCorr3DMM(unittest.TestCase):
...
@@ -66,27 +68,26 @@ class TestCorr3DMM(unittest.TestCase):
subsample
=
(
1
,
2
,
3
))
subsample
=
(
1
,
2
,
3
))
def
run_gradweight
(
self
,
inputs_shape
,
filters_shape
,
dCdH_shape
,
def
run_gradweight
(
self
,
inputs_shape
,
filters_shape
,
dCdH_shape
,
subsample
=
(
1
,
1
,
1
)):
subsample
=
(
1
,
1
,
1
)):
inputs_val
=
numpy
.
random
.
random
(
inputs_shape
)
.
astype
(
'float32'
)
inputs_val
=
numpy
.
random
.
random
(
inputs_shape
)
.
astype
(
'float32'
)
dCdH_val
=
numpy
.
random
.
random
(
dCdH_shape
)
.
astype
(
'float32'
)
dCdH_val
=
numpy
.
random
.
random
(
dCdH_shape
)
.
astype
(
'float32'
)
inputs
=
shared
(
inputs_val
)
inputs
=
shared
(
inputs_val
)
dCdH
=
shared
(
dCdH_val
)
dCdH
=
shared
(
dCdH_val
)
conv
=
theano
.
tensor
.
nnet
.
convGrad3D
(
V
=
inputs
,
dCdH
=
dCdH
,
conv
=
theano
.
tensor
.
nnet
.
convGrad3D
(
V
=
inputs
,
dCdH
=
dCdH
,
WShape
=
filters_shape
,
WShape
=
filters_shape
,
d
=
subsample
)
d
=
subsample
)
img
=
gpu_contiguous
(
inputs
.
dimshuffle
(
0
,
4
,
1
,
2
,
3
))
img
=
gpu_contiguous
(
inputs
.
dimshuffle
(
0
,
4
,
1
,
2
,
3
))
topgrad
=
gpu_contiguous
(
dCdH
.
dimshuffle
(
0
,
4
,
1
,
2
,
3
))
topgrad
=
gpu_contiguous
(
dCdH
.
dimshuffle
(
0
,
4
,
1
,
2
,
3
))
if
(
subsample
==
(
1
,
1
,
1
)):
if
(
subsample
==
(
1
,
1
,
1
)):
conv_gemm
=
GpuCorr3dMM_gradWeights
(
subsample
=
subsample
)(
img
,
conv_gemm
=
GpuCorr3dMM_gradWeights
(
subsample
=
subsample
)(
img
,
topgrad
)
topgrad
)
else
:
else
:
conv_gemm
=
GpuCorr3dMM_gradWeights
(
subsample
=
subsample
)(
img
,
conv_gemm
=
GpuCorr3dMM_gradWeights
(
subsample
=
subsample
)(
topgrad
,
img
,
topgrad
,
shape
=
filters_shape
[
1
:
4
])
shape
=
filters_shape
[
1
:
4
])
conv_gemm
=
conv_gemm
.
dimshuffle
(
0
,
2
,
3
,
4
,
1
)
conv_gemm
=
conv_gemm
.
dimshuffle
(
0
,
2
,
3
,
4
,
1
)
f_ref
=
theano
.
function
([],
conv
)
f_ref
=
theano
.
function
([],
conv
)
f
=
theano
.
function
([],
conv_gemm
)
f
=
theano
.
function
([],
conv_gemm
,
mode
=
mode_with_gpu
)
res_ref
=
f_ref
()
res_ref
=
f_ref
()
res
=
f
()
res
=
f
()
...
@@ -124,7 +125,7 @@ class TestCorr3DMM(unittest.TestCase):
...
@@ -124,7 +125,7 @@ class TestCorr3DMM(unittest.TestCase):
f_ref
=
theano
.
function
([],
conv
)
f_ref
=
theano
.
function
([],
conv
)
res_ref
=
f_ref
()
res_ref
=
f_ref
()
#
##
Get bottom shape using convTransp3D
# Get bottom shape using convTransp3D
bottom_shape
=
res_ref
.
shape
bottom_shape
=
res_ref
.
shape
bottom_val
=
numpy
.
random
.
random
(
bottom_shape
)
.
astype
(
'float32'
)
bottom_val
=
numpy
.
random
.
random
(
bottom_shape
)
.
astype
(
'float32'
)
bottom
=
shared
(
bottom_val
)
bottom
=
shared
(
bottom_val
)
...
@@ -132,12 +133,14 @@ class TestCorr3DMM(unittest.TestCase):
...
@@ -132,12 +133,14 @@ class TestCorr3DMM(unittest.TestCase):
weight
=
gpu_contiguous
(
filters
.
dimshuffle
(
0
,
4
,
1
,
2
,
3
))
weight
=
gpu_contiguous
(
filters
.
dimshuffle
(
0
,
4
,
1
,
2
,
3
))
top
=
gpu_contiguous
(
inputs
.
dimshuffle
(
0
,
4
,
1
,
2
,
3
))
top
=
gpu_contiguous
(
inputs
.
dimshuffle
(
0
,
4
,
1
,
2
,
3
))
if
(
subsample
==
(
1
,
1
,
1
)):
if
(
subsample
==
(
1
,
1
,
1
)):
conv_gemm
=
GpuCorr3dMM_gradInputs
(
subsample
=
subsample
)(
kern
=
weight
,
topgrad
=
top
)
conv_gemm
=
GpuCorr3dMM_gradInputs
(
subsample
=
subsample
)(
kern
=
weight
,
topgrad
=
top
)
else
:
else
:
conv_gemm
=
GpuCorr3dMM_gradInputs
(
subsample
=
subsample
)(
kern
=
weight
,
topgrad
=
top
,
conv_gemm
=
GpuCorr3dMM_gradInputs
(
subsample
=
subsample
)(
shape
=
bottom
.
shape
[
1
:
4
])
kern
=
weight
,
topgrad
=
top
,
shape
=
bottom
.
shape
[
1
:
4
])
conv_gemm
=
conv_gemm
.
dimshuffle
(
0
,
2
,
3
,
4
,
1
)
conv_gemm
=
conv_gemm
.
dimshuffle
(
0
,
2
,
3
,
4
,
1
)
f
=
theano
.
function
([],
conv_gemm
)
f
=
theano
.
function
([],
conv_gemm
,
mode
=
mode_with_gpu
)
res
=
f
()
res
=
f
()
utt
.
assert_allclose
(
res_ref
,
res
)
utt
.
assert_allclose
(
res_ref
,
res
)
...
@@ -147,14 +150,13 @@ class TestCorr3DMM(unittest.TestCase):
...
@@ -147,14 +150,13 @@ class TestCorr3DMM(unittest.TestCase):
filters_shape
=
(
10
,
6
,
12
,
4
,
1
))
filters_shape
=
(
10
,
6
,
12
,
4
,
1
))
self
.
run_gradinput
(
inputs_shape
=
(
16
,
15
,
12
,
12
,
10
),
self
.
run_gradinput
(
inputs_shape
=
(
16
,
15
,
12
,
12
,
10
),
filters_shape
=
(
10
,
6
,
12
,
4
,
1
),
filters_shape
=
(
10
,
6
,
12
,
4
,
1
),
subsample
=
(
2
,
2
,
2
))
subsample
=
(
2
,
2
,
2
))
self
.
run_gradinput
(
inputs_shape
=
(
16
,
15
,
12
,
12
,
10
),
self
.
run_gradinput
(
inputs_shape
=
(
16
,
15
,
12
,
12
,
10
),
filters_shape
=
(
10
,
6
,
12
,
4
,
1
),
filters_shape
=
(
10
,
6
,
12
,
4
,
1
),
subsample
=
(
3
,
3
,
3
))
subsample
=
(
3
,
3
,
3
))
self
.
run_gradinput
(
inputs_shape
=
(
16
,
15
,
12
,
12
,
10
),
self
.
run_gradinput
(
inputs_shape
=
(
16
,
15
,
12
,
12
,
10
),
filters_shape
=
(
10
,
6
,
12
,
4
,
1
),
filters_shape
=
(
10
,
6
,
12
,
4
,
1
),
subsample
=
(
3
,
1
,
2
))
subsample
=
(
3
,
1
,
2
))
def
test_opt_conv3d_gemm
(
self
):
def
test_opt_conv3d_gemm
(
self
):
inputs_shape
=
(
16
,
20
,
32
,
16
,
1
)
inputs_shape
=
(
16
,
20
,
32
,
16
,
1
)
...
@@ -168,7 +170,7 @@ class TestCorr3DMM(unittest.TestCase):
...
@@ -168,7 +170,7 @@ class TestCorr3DMM(unittest.TestCase):
bias
=
shared
(
numpy
.
zeros
(
filters_shape
[
0
])
.
astype
(
'float32'
))
bias
=
shared
(
numpy
.
zeros
(
filters_shape
[
0
])
.
astype
(
'float32'
))
conv
=
theano
.
tensor
.
nnet
.
conv3D
(
V
=
inputs
,
W
=
filters
,
conv
=
theano
.
tensor
.
nnet
.
conv3D
(
V
=
inputs
,
W
=
filters
,
b
=
bias
,
d
=
(
1
,
1
,
1
))
b
=
bias
,
d
=
(
1
,
1
,
1
))
mode
=
mode_with_gpu
.
including
(
'conv3d_gemm'
)
mode
=
mode_with_gpu
.
including
(
'conv3d_gemm'
)
f_ref
=
theano
.
function
([],
conv
)
f_ref
=
theano
.
function
([],
conv
)
...
@@ -195,7 +197,7 @@ class TestCorr3DMM(unittest.TestCase):
...
@@ -195,7 +197,7 @@ class TestCorr3DMM(unittest.TestCase):
conv
=
theano
.
tensor
.
nnet
.
convGrad3D
(
V
=
inputs
,
dCdH
=
dCdH
,
conv
=
theano
.
tensor
.
nnet
.
convGrad3D
(
V
=
inputs
,
dCdH
=
dCdH
,
WShape
=
filters_shape
,
WShape
=
filters_shape
,
d
=
(
1
,
1
,
1
))
d
=
(
1
,
1
,
1
))
mode
=
mode_with_gpu
.
including
(
'convgrad3d_gemm'
)
mode
=
mode_with_gpu
.
including
(
'convgrad3d_gemm'
)
f_ref
=
theano
.
function
([],
conv
)
f_ref
=
theano
.
function
([],
conv
)
...
@@ -209,7 +211,6 @@ class TestCorr3DMM(unittest.TestCase):
...
@@ -209,7 +211,6 @@ class TestCorr3DMM(unittest.TestCase):
res_gemm
=
f_gemm
()
res_gemm
=
f_gemm
()
utt
.
assert_allclose
(
res_ref
,
res_gemm
)
utt
.
assert_allclose
(
res_ref
,
res_gemm
)
def
test_opt_convtransp3d_gemm
(
self
):
def
test_opt_convtransp3d_gemm
(
self
):
inputs_shape
=
(
16
,
15
,
12
,
12
,
10
)
inputs_shape
=
(
16
,
15
,
12
,
12
,
10
)
filters_shape
=
(
10
,
6
,
12
,
4
,
1
)
filters_shape
=
(
10
,
6
,
12
,
4
,
1
)
...
@@ -221,7 +222,7 @@ class TestCorr3DMM(unittest.TestCase):
...
@@ -221,7 +222,7 @@ class TestCorr3DMM(unittest.TestCase):
inputs
=
shared
(
inputs_val
)
inputs
=
shared
(
inputs_val
)
filters
=
shared
(
filters_val
)
filters
=
shared
(
filters_val
)
conv
=
theano
.
tensor
.
nnet
.
convTransp3D
(
W
=
filters
,
b
=
bias
,
d
=
(
1
,
1
,
1
),
conv
=
theano
.
tensor
.
nnet
.
convTransp3D
(
W
=
filters
,
b
=
bias
,
d
=
(
1
,
1
,
1
),
H
=
inputs
)
H
=
inputs
)
mode
=
mode_with_gpu
.
including
(
'convtransp3d_gemm'
)
mode
=
mode_with_gpu
.
including
(
'convtransp3d_gemm'
)
...
@@ -235,4 +236,3 @@ class TestCorr3DMM(unittest.TestCase):
...
@@ -235,4 +236,3 @@ class TestCorr3DMM(unittest.TestCase):
res_ref
=
f_ref
()
res_ref
=
f_ref
()
res_gemm
=
f_gemm
()
res_gemm
=
f_gemm
()
utt
.
assert_allclose
(
res_ref
,
res_gemm
)
utt
.
assert_allclose
(
res_ref
,
res_gemm
)
theano/tensor/tests/test_opt.py
浏览文件 @
34a45383
...
@@ -1576,12 +1576,13 @@ def test_log_add():
...
@@ -1576,12 +1576,13 @@ def test_log_add():
def
test_local_useless_inc_subtensor
():
def
test_local_useless_inc_subtensor
():
x
=
tensor
.
matrix
(
'x'
)
x
=
tensor
.
matrix
(
'x'
)
y
=
tensor
.
matrix
(
'y'
)
y
=
tensor
.
matrix
(
'y'
)
mode
=
compile
.
get_default_mode
()
.
including
(
"local_useless_inc_subtensor"
)
for
sub
in
[
slice
(
None
),
slice
(
None
,
None
,
-
1
)]:
for
sub
in
[
slice
(
None
),
slice
(
None
,
None
,
-
1
)]:
o
=
tensor
.
set_subtensor
(
x
[::,
sub
],
y
)
o
=
tensor
.
set_subtensor
(
x
[::,
sub
],
y
)
f
=
theano
.
function
([
x
,
y
],
o
)
f
=
theano
.
function
([
x
,
y
],
o
,
mode
=
mode
)
o_shape
=
tensor
.
set_subtensor
(
x
[::,
sub
],
o_shape
=
tensor
.
set_subtensor
(
x
[::,
sub
],
tensor
.
specify_shape
(
y
,
x
.
shape
))
tensor
.
specify_shape
(
y
,
x
.
shape
))
f_shape
=
theano
.
function
([
x
,
y
],
o_shape
)
f_shape
=
theano
.
function
([
x
,
y
],
o_shape
,
mode
=
mode
)
# Test with shape info
# Test with shape info
topo
=
f_shape
.
maker
.
fgraph
.
toposort
()
topo
=
f_shape
.
maker
.
fgraph
.
toposort
()
...
@@ -1614,7 +1615,7 @@ def test_local_useless_inc_subtensor():
...
@@ -1614,7 +1615,7 @@ def test_local_useless_inc_subtensor():
tensor
.
specify_shape
(
y
,
sub
.
shape
))
tensor
.
specify_shape
(
y
,
sub
.
shape
))
f_shape
=
theano
.
function
([
x
,
y
],
o_shape
)
f_shape
=
theano
.
function
([
x
,
y
],
o_shape
)
topo
=
f_shape
.
maker
.
fgraph
.
toposort
()
topo
=
f_shape
.
maker
.
fgraph
.
toposort
()
theano
.
printing
.
debugprint
(
f_shape
)
#
theano.printing.debugprint(f_shape)
assert
any
(
isinstance
(
n
.
op
,
tensor
.
IncSubtensor
)
for
n
in
topo
)
assert
any
(
isinstance
(
n
.
op
,
tensor
.
IncSubtensor
)
for
n
in
topo
)
out
=
f_shape
([[
2
,
3
,
6
,
7
]],
[[
8
,
9
]])
out
=
f_shape
([[
2
,
3
,
6
,
7
]],
[[
8
,
9
]])
assert
(
out
==
numpy
.
asarray
([[
8
,
3
,
9
,
7
]]))
.
all
()
assert
(
out
==
numpy
.
asarray
([[
8
,
3
,
9
,
7
]]))
.
all
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论