Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b8e58590
提交
b8e58590
authored
3月 01, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a warning when doing infer_shape but when the inputs have dimensions of the same size.
This can hid error.
上级
1617a923
显示空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
69 行增加
和
51 行删除
+69
-51
test_linalg.py
theano/sandbox/linalg/tests/test_linalg.py
+6
-3
test_basic.py
theano/sparse/tests/test_basic.py
+9
-3
test_sp2.py
theano/sparse/tests/test_sp2.py
+2
-1
test_conv.py
theano/tensor/nnet/tests/test_conv.py
+10
-30
test_downsample.py
theano/tensor/signal/tests/test_downsample.py
+2
-3
test_basic.py
theano/tensor/tests/test_basic.py
+11
-7
test_elemwise.py
theano/tensor/tests/test_elemwise.py
+2
-1
test_extra_ops.py
theano/tensor/tests/test_extra_ops.py
+5
-2
unittest_tools.py
theano/tests/unittest_tools.py
+22
-1
没有找到文件。
theano/sandbox/linalg/tests/test_linalg.py
浏览文件 @
b8e58590
...
@@ -463,7 +463,8 @@ class test_Solve(utt.InferShapeTester):
...
@@ -463,7 +463,8 @@ class test_Solve(utt.InferShapeTester):
dtype
=
config
.
floatX
),
dtype
=
config
.
floatX
),
numpy
.
asarray
(
rng
.
rand
(
5
,
1
),
numpy
.
asarray
(
rng
.
rand
(
5
,
1
),
dtype
=
config
.
floatX
)],
dtype
=
config
.
floatX
)],
self
.
op_class
)
self
.
op_class
,
warn
=
False
)
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
A
=
theano
.
tensor
.
matrix
()
A
=
theano
.
tensor
.
matrix
()
b
=
theano
.
tensor
.
vector
()
b
=
theano
.
tensor
.
vector
()
...
@@ -474,7 +475,8 @@ class test_Solve(utt.InferShapeTester):
...
@@ -474,7 +475,8 @@ class test_Solve(utt.InferShapeTester):
dtype
=
config
.
floatX
),
dtype
=
config
.
floatX
),
numpy
.
asarray
(
rng
.
rand
(
5
),
numpy
.
asarray
(
rng
.
rand
(
5
),
dtype
=
config
.
floatX
)],
dtype
=
config
.
floatX
)],
self
.
op_class
)
self
.
op_class
,
warn
=
False
)
class
test_Eig
(
utt
.
InferShapeTester
):
class
test_Eig
(
utt
.
InferShapeTester
):
...
@@ -497,7 +499,8 @@ class test_Eig(utt.InferShapeTester):
...
@@ -497,7 +499,8 @@ class test_Eig(utt.InferShapeTester):
self
.
op
(
A
),
# theano.function outputs
self
.
op
(
A
),
# theano.function outputs
# S must be square
# S must be square
[
S
],
[
S
],
self
.
op_class
)
self
.
op_class
,
warn
=
False
)
def
test_eval
(
self
):
def
test_eval
(
self
):
import
math
import
math
...
...
theano/sparse/tests/test_basic.py
浏览文件 @
b8e58590
...
@@ -1615,7 +1615,8 @@ class DiagTester(utt.InferShapeTester):
...
@@ -1615,7 +1615,8 @@ class DiagTester(utt.InferShapeTester):
self
.
_compile_and_check
(
variable
,
self
.
_compile_and_check
(
variable
,
[
self
.
op
(
*
variable
)],
[
self
.
op
(
*
variable
)],
data
,
data
,
self
.
op_class
)
self
.
op_class
,
warn
=
False
)
def
test_grad
(
self
):
def
test_grad
(
self
):
for
format
in
sparse
.
sparse_formats
:
for
format
in
sparse
.
sparse_formats
:
...
@@ -2591,9 +2592,14 @@ class StructuredAddSVTester(unittest.TestCase):
...
@@ -2591,9 +2592,14 @@ class StructuredAddSVTester(unittest.TestCase):
class
SamplingDotTester
(
utt
.
InferShapeTester
):
class
SamplingDotTester
(
utt
.
InferShapeTester
):
x
=
[
tensor
.
matrix
()
for
t
in
range
(
2
)]
x
=
[
tensor
.
matrix
()
for
t
in
range
(
2
)]
x
.
append
(
sparse
.
csr_matrix
())
x
.
append
(
sparse
.
csr_matrix
())
a
=
[
numpy
.
array
(
numpy
.
random
.
random_integers
(
maximum
,
size
=
(
3
,
3
))
-
1
,
#unsquare shape
a
=
[
numpy
.
array
(
numpy
.
random
.
random_integers
(
5
,
size
=
(
4
,
3
))
-
1
,
dtype
=
theano
.
config
.
floatX
),
numpy
.
array
(
numpy
.
random
.
random_integers
(
5
,
size
=
(
5
,
3
))
-
1
,
dtype
=
theano
.
config
.
floatX
),
numpy
.
array
(
numpy
.
random
.
random_integers
(
2
,
size
=
(
4
,
5
))
-
1
,
dtype
=
theano
.
config
.
floatX
)
dtype
=
theano
.
config
.
floatX
)
for
maximum
in
[
5
,
5
,
2
]
]
]
a
[
2
]
=
sp
.
csr_matrix
(
a
[
2
])
a
[
2
]
=
sp
.
csr_matrix
(
a
[
2
])
def
setUp
(
self
):
def
setUp
(
self
):
...
...
theano/sparse/tests/test_sp2.py
浏览文件 @
b8e58590
...
@@ -135,7 +135,8 @@ class MultinomialTester(utt.InferShapeTester):
...
@@ -135,7 +135,8 @@ class MultinomialTester(utt.InferShapeTester):
self
.
_compile_and_check
([
self
.
p
],
self
.
_compile_and_check
([
self
.
p
],
[
multinomial
(
5
,
self
.
p
)],
[
multinomial
(
5
,
self
.
p
)],
[
self
.
_p
],
[
self
.
_p
],
self
.
op_class
)
self
.
op_class
,
warn
=
False
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
theano/tensor/nnet/tests/test_conv.py
浏览文件 @
b8e58590
...
@@ -424,82 +424,62 @@ class TestConv2D(utt.InferShapeTester):
...
@@ -424,82 +424,62 @@ class TestConv2D(utt.InferShapeTester):
adtens
=
T
.
dtensor4
()
adtens
=
T
.
dtensor4
()
bdtens
=
T
.
dtensor4
()
bdtens
=
T
.
dtensor4
()
aivec_val
=
[
2
,
2
,
3
,
3
]
aivec_val
=
[
4
,
5
,
6
,
3
]
bivec_val
=
[
2
,
2
,
2
,
2
]
bivec_val
=
[
7
,
5
,
3
,
2
]
adtens_val
=
rand
(
*
aivec_val
)
adtens_val
=
rand
(
*
aivec_val
)
bdtens_val
=
rand
(
*
bivec_val
)
bdtens_val
=
rand
(
*
bivec_val
)
self
.
_compile_and_check
([
adtens
,
bdtens
],
self
.
_compile_and_check
([
adtens
,
bdtens
],
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
border_mode
=
'valid'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
border_mode
=
'valid'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
aivec_val
=
[
2
,
2
,
3
,
3
]
bivec_val
=
[
2
,
2
,
2
,
2
]
adtens_val
=
rand
(
*
aivec_val
)
bdtens_val
=
rand
(
*
bivec_val
)
self
.
_compile_and_check
([
adtens
,
bdtens
],
self
.
_compile_and_check
([
adtens
,
bdtens
],
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
border_mode
=
'full'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
border_mode
=
'full'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
aivec_val
=
[
3
,
2
,
8
,
8
]
aivec_val
=
[
6
,
2
,
8
,
3
]
bivec_val
=
[
4
,
2
,
5
,
5
]
bivec_val
=
[
4
,
2
,
5
,
3
]
adtens_val
=
rand
(
*
aivec_val
)
adtens_val
=
rand
(
*
aivec_val
)
bdtens_val
=
rand
(
*
bivec_val
)
bdtens_val
=
rand
(
*
bivec_val
)
self
.
_compile_and_check
([
adtens
,
bdtens
],
self
.
_compile_and_check
([
adtens
,
bdtens
],
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
border_mode
=
'valid'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
border_mode
=
'valid'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
aivec_val
=
[
3
,
2
,
8
,
8
]
bivec_val
=
[
4
,
2
,
5
,
5
]
adtens_val
=
rand
(
*
aivec_val
)
bdtens_val
=
rand
(
*
bivec_val
)
self
.
_compile_and_check
([
adtens
,
bdtens
],
self
.
_compile_and_check
([
adtens
,
bdtens
],
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
border_mode
=
'full'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
border_mode
=
'full'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
aivec_val
=
[
3
,
2
,
7
,
5
]
aivec_val
=
[
3
,
6
,
7
,
5
]
bivec_val
=
[
5
,
2
,
3
,
2
]
bivec_val
=
[
5
,
6
,
3
,
2
]
adtens_val
=
rand
(
*
aivec_val
)
adtens_val
=
rand
(
*
aivec_val
)
bdtens_val
=
rand
(
*
bivec_val
)
bdtens_val
=
rand
(
*
bivec_val
)
self
.
_compile_and_check
([
adtens
,
bdtens
],
self
.
_compile_and_check
([
adtens
,
bdtens
],
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
border_mode
=
'valid'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
border_mode
=
'valid'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
aivec_val
=
[
3
,
2
,
7
,
5
]
bivec_val
=
[
5
,
2
,
3
,
2
]
adtens_val
=
rand
(
*
aivec_val
)
bdtens_val
=
rand
(
*
bivec_val
)
self
.
_compile_and_check
([
adtens
,
bdtens
],
self
.
_compile_and_check
([
adtens
,
bdtens
],
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
border_mode
=
'full'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
border_mode
=
'full'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
aivec_val
=
[
3
,
2
,
7
,
5
]
aivec_val
=
[
3
,
6
,
7
,
5
]
bivec_val
=
[
5
,
2
,
2
,
3
]
bivec_val
=
[
5
,
6
,
2
,
3
]
adtens_val
=
rand
(
*
aivec_val
)
adtens_val
=
rand
(
*
aivec_val
)
bdtens_val
=
rand
(
*
bivec_val
)
bdtens_val
=
rand
(
*
bivec_val
)
self
.
_compile_and_check
([
adtens
,
bdtens
],
self
.
_compile_and_check
([
adtens
,
bdtens
],
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
border_mode
=
'valid'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
border_mode
=
'valid'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
aivec_val
=
[
3
,
2
,
7
,
5
]
bivec_val
=
[
5
,
2
,
2
,
3
]
adtens_val
=
rand
(
*
aivec_val
)
bdtens_val
=
rand
(
*
bivec_val
)
self
.
_compile_and_check
([
adtens
,
bdtens
],
self
.
_compile_and_check
([
adtens
,
bdtens
],
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
border_mode
=
'full'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
border_mode
=
'full'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
aivec_val
=
[
3
,
2
,
3
,
3
]
aivec_val
=
[
5
,
2
,
4
,
3
]
bivec_val
=
[
4
,
2
,
3
,
3
]
bivec_val
=
[
6
,
2
,
4
,
3
]
adtens_val
=
rand
(
*
aivec_val
)
adtens_val
=
rand
(
*
aivec_val
)
bdtens_val
=
rand
(
*
bivec_val
)
bdtens_val
=
rand
(
*
bivec_val
)
self
.
_compile_and_check
([
adtens
,
bdtens
],
self
.
_compile_and_check
([
adtens
,
bdtens
],
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
border_mode
=
'valid'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
border_mode
=
'valid'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
aivec_val
=
[
3
,
2
,
3
,
3
]
bivec_val
=
[
4
,
2
,
3
,
3
]
adtens_val
=
rand
(
*
aivec_val
)
bdtens_val
=
rand
(
*
bivec_val
)
self
.
_compile_and_check
([
adtens
,
bdtens
],
self
.
_compile_and_check
([
adtens
,
bdtens
],
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
[
conv
.
conv2d
(
adtens
,
bdtens
,
aivec_val
,
bivec_val
,
border_mode
=
'full'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
border_mode
=
'full'
)],
[
adtens_val
,
bdtens_val
],
conv
.
ConvOp
)
...
...
theano/tensor/signal/tests/test_downsample.py
浏览文件 @
b8e58590
...
@@ -182,9 +182,8 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
...
@@ -182,9 +182,8 @@ class TestDownsampleFactorMax(utt.InferShapeTester):
[
DownsampleFactorMaxGrad
(
maxpoolshp
,
[
DownsampleFactorMaxGrad
(
maxpoolshp
,
ignore_border
=
ignore_border
)(
image
,
maxout
,
gz
)],
ignore_border
=
ignore_border
)(
image
,
maxout
,
gz
)],
[
image_val
,
maxout_val
,
gz_val
],
[
image_val
,
maxout_val
,
gz_val
],
DownsampleFactorMaxGrad
)
DownsampleFactorMaxGrad
,
warn
=
False
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
b8e58590
...
@@ -6743,7 +6743,7 @@ class TestInferShape(utt.InferShapeTester):
...
@@ -6743,7 +6743,7 @@ class TestInferShape(utt.InferShapeTester):
# Join
# Join
cdmat
=
dmatrix
()
cdmat
=
dmatrix
()
admat_val
=
rand
(
1
,
3
)
admat_val
=
rand
(
1
,
3
)
bdmat_val
=
rand
(
3
,
3
)
bdmat_val
=
rand
(
2
,
3
)
cdmat_val
=
rand
(
4
,
3
)
cdmat_val
=
rand
(
4
,
3
)
aiscal_val
=
0
aiscal_val
=
0
self
.
_compile_and_check
([
aiscal
,
admat
,
bdmat
,
cdmat
],
self
.
_compile_and_check
([
aiscal
,
admat
,
bdmat
,
cdmat
],
...
@@ -6821,7 +6821,8 @@ class TestInferShape(utt.InferShapeTester):
...
@@ -6821,7 +6821,8 @@ class TestInferShape(utt.InferShapeTester):
adtens4_val
=
rand
(
2
,
1
,
3
,
1
)
adtens4_val
=
rand
(
2
,
1
,
3
,
1
)
self
.
_compile_and_check
([
adtens4
],
self
.
_compile_and_check
([
adtens4
],
[
Rebroadcast
(
*
adict
)(
adtens4
)],
[
Rebroadcast
(
*
adict
)(
adtens4
)],
[
adtens4_val
],
Rebroadcast
)
[
adtens4_val
],
Rebroadcast
,
warn
=
False
)
adtens4_bro
=
TensorType
(
'float64'
,
(
True
,
True
,
True
,
False
))()
adtens4_bro
=
TensorType
(
'float64'
,
(
True
,
True
,
True
,
False
))()
bdict
=
[(
0
,
True
),
(
1
,
False
),
(
2
,
False
),
(
3
,
False
)]
bdict
=
[(
0
,
True
),
(
1
,
False
),
(
2
,
False
),
(
3
,
False
)]
...
@@ -6948,8 +6949,8 @@ class TestInferShape(utt.InferShapeTester):
...
@@ -6948,8 +6949,8 @@ class TestInferShape(utt.InferShapeTester):
adtens4_val
=
rand
(
3
,
4
,
2
,
5
)
adtens4_val
=
rand
(
3
,
4
,
2
,
5
)
self
.
_compile_and_check
([
adtens4
,
bdtens4
],
self
.
_compile_and_check
([
adtens4
,
bdtens4
],
[
inc_subtensor
(
adtens4
[::,
2
:
4
,
::,
::],
bdtens4
)],
[
inc_subtensor
(
adtens4
[::,
2
:
4
,
::,
::],
bdtens4
)],
[
adtens4_val
,
[[[[
1
,
2
,
3
,
4
,
5
]]]]],
IncSubtensor
)
[
adtens4_val
,
[[[[
1
,
2
,
3
,
4
,
5
]]]]],
IncSubtensor
,
warn
=
False
)
self
.
_compile_and_check
([
adtens4
,
bdmat
],
self
.
_compile_and_check
([
adtens4
,
bdmat
],
[
inc_subtensor
(
adtens4
[
2
,
2
:
4
,
1
,
::],
bdmat
)],
[
inc_subtensor
(
adtens4
[
2
,
2
:
4
,
1
,
::],
bdmat
)],
[
adtens4_val
,
[[
1
,
2
,
3
,
4
,
5
]]],
IncSubtensor
)
[
adtens4_val
,
[[
1
,
2
,
3
,
4
,
5
]]],
IncSubtensor
)
...
@@ -6964,7 +6965,8 @@ class TestInferShape(utt.InferShapeTester):
...
@@ -6964,7 +6965,8 @@ class TestInferShape(utt.InferShapeTester):
self
.
_compile_and_check
([
adtens4
,
bdtens4
],
self
.
_compile_and_check
([
adtens4
,
bdtens4
],
[
set_subtensor
(
adtens4
[::,
2
:
4
,
::,
::],
bdtens4
)],
[
set_subtensor
(
adtens4
[::,
2
:
4
,
::,
::],
bdtens4
)],
[
adtens4_val
,
[[[[
1
,
2
,
3
,
4
,
5
]]]]],
IncSubtensor
)
[
adtens4_val
,
[[[[
1
,
2
,
3
,
4
,
5
]]]]],
IncSubtensor
,
warn
=
False
)
self
.
_compile_and_check
([
adtens4
,
bdmat
],
self
.
_compile_and_check
([
adtens4
,
bdmat
],
[
set_subtensor
(
adtens4
[
2
,
2
:
4
,
1
,
::],
bdmat
)],
[
set_subtensor
(
adtens4
[
2
,
2
:
4
,
1
,
::],
bdmat
)],
...
@@ -7005,7 +7007,8 @@ class TestInferShape(utt.InferShapeTester):
...
@@ -7005,7 +7007,8 @@ class TestInferShape(utt.InferShapeTester):
self
.
_compile_and_check
([
adtens4
,
bdtens4
],
self
.
_compile_and_check
([
adtens4
,
bdtens4
],
[
set_subtensor
(
adtens4
[
aivec_val
],
bdtens4
)],
[
set_subtensor
(
adtens4
[
aivec_val
],
bdtens4
)],
[
adtens4_val
,
[[[[
1
,
2
,
3
,
4
,
5
]]]]],
[
adtens4_val
,
[[[[
1
,
2
,
3
,
4
,
5
]]]]],
AdvancedIncSubtensor1
)
AdvancedIncSubtensor1
,
warn
=
False
)
aivec_val
=
[
1
,
3
,
2
]
aivec_val
=
[
1
,
3
,
2
]
self
.
_compile_and_check
([
adtens4
,
advec
],
self
.
_compile_and_check
([
adtens4
,
advec
],
...
@@ -7042,7 +7045,8 @@ class TestInferShape(utt.InferShapeTester):
...
@@ -7042,7 +7045,8 @@ class TestInferShape(utt.InferShapeTester):
[
inc_subtensor
(
adtens4
[
aivec_val
],
bdtens4
)],
[
inc_subtensor
(
adtens4
[
aivec_val
],
bdtens4
)],
[
adtens4_val
,
[[[[
1
,
2
,
3
,
4
,
5
]]],
[
adtens4_val
,
[[[[
1
,
2
,
3
,
4
,
5
]]],
[[[
6
,
7
,
8
,
9
,
10
]]]]],
[[[
6
,
7
,
8
,
9
,
10
]]]]],
AdvancedIncSubtensor1
)
AdvancedIncSubtensor1
,
warn
=
False
)
aivec_val
=
[
1
,
2
,
1
]
aivec_val
=
[
1
,
2
,
1
]
self
.
_compile_and_check
([
adtens4
,
advec
],
self
.
_compile_and_check
([
adtens4
,
advec
],
...
...
theano/tensor/tests/test_elemwise.py
浏览文件 @
b8e58590
...
@@ -93,7 +93,8 @@ class test_DimShuffle(unittest_tools.InferShapeTester):
...
@@ -93,7 +93,8 @@ class test_DimShuffle(unittest_tools.InferShapeTester):
adtens_val
=
numpy
.
ones
(
xsh
)
adtens_val
=
numpy
.
ones
(
xsh
)
self
.
_compile_and_check
([
adtens
],
self
.
_compile_and_check
([
adtens
],
[
DimShuffle
(
ib
,
shuffle
)(
adtens
)],
[
DimShuffle
(
ib
,
shuffle
)(
adtens
)],
[
adtens_val
],
DimShuffle
)
[
adtens_val
],
DimShuffle
,
warn
=
False
)
def
test_too_big_rank
(
self
):
def
test_too_big_rank
(
self
):
x
=
tensor
.
dscalar
()
x
=
tensor
.
dscalar
()
...
...
theano/tensor/tests/test_extra_ops.py
浏览文件 @
b8e58590
...
@@ -182,7 +182,8 @@ class SqueezeTester(utt.InferShapeTester):
...
@@ -182,7 +182,8 @@ class SqueezeTester(utt.InferShapeTester):
self
.
_compile_and_check
([
variable
],
self
.
_compile_and_check
([
variable
],
[
self
.
op
(
variable
)],
[
self
.
op
(
variable
)],
[
data
],
[
data
],
tensor
.
DimShuffle
)
tensor
.
DimShuffle
,
warn
=
False
)
def
test_grad
(
self
):
def
test_grad
(
self
):
for
shape
,
broadcast
in
zip
(
self
.
shape_list
,
self
.
broadcast_list
):
for
shape
,
broadcast
in
zip
(
self
.
shape_list
,
self
.
broadcast_list
):
...
@@ -375,9 +376,11 @@ class TestFillDiagonal(utt.InferShapeTester):
...
@@ -375,9 +376,11 @@ class TestFillDiagonal(utt.InferShapeTester):
numpy
.
random
.
rand
()],
numpy
.
random
.
rand
()],
self
.
op_class
)
self
.
op_class
)
self
.
_compile_and_check
([
z
,
y
],
[
self
.
op
(
z
,
y
)],
self
.
_compile_and_check
([
z
,
y
],
[
self
.
op
(
z
,
y
)],
#must be square when nd>2
[
numpy
.
random
.
rand
(
8
,
8
,
8
),
[
numpy
.
random
.
rand
(
8
,
8
,
8
),
numpy
.
random
.
rand
()],
numpy
.
random
.
rand
()],
self
.
op_class
)
self
.
op_class
,
warn
=
False
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
utt
.
unittest
.
main
()
utt
.
unittest
.
main
()
...
...
theano/tests/unittest_tools.py
浏览文件 @
b8e58590
from
copy
import
copy
,
deepcopy
from
copy
import
copy
,
deepcopy
import
logging
import
sys
import
sys
import
unittest
import
unittest
...
@@ -15,6 +16,7 @@ except ImportError:
...
@@ -15,6 +16,7 @@ except ImportError:
"""
"""
Skip this test
Skip this test
"""
"""
_logger
=
logging
.
getLogger
(
"theano.tests.unittest_tools"
)
AddConfigVar
(
'unittests.rseed'
,
AddConfigVar
(
'unittests.rseed'
,
...
@@ -173,11 +175,30 @@ class InferShapeTester(unittest.TestCase):
...
@@ -173,11 +175,30 @@ class InferShapeTester(unittest.TestCase):
self
.
mode
=
mode
.
including
(
"canonicalize"
)
self
.
mode
=
mode
.
including
(
"canonicalize"
)
def
_compile_and_check
(
self
,
inputs
,
outputs
,
numeric_inputs
,
cls
,
def
_compile_and_check
(
self
,
inputs
,
outputs
,
numeric_inputs
,
cls
,
excluding
=
None
):
excluding
=
None
,
warn
=
True
):
"""This tests the infer_shape method only"""
"""This tests the infer_shape method only"""
mode
=
self
.
mode
mode
=
self
.
mode
if
excluding
:
if
excluding
:
mode
=
mode
.
excluding
(
*
excluding
)
mode
=
mode
.
excluding
(
*
excluding
)
if
warn
:
for
var
,
inp
in
zip
(
inputs
,
numeric_inputs
):
if
isinstance
(
inp
,
(
int
,
float
,
list
,
tuple
)):
inp
=
var
.
type
.
filter
(
inp
)
if
not
hasattr
(
inp
,
"shape"
):
continue
# remove broadcasted dims as it is sure they can't be
# changed to prevent the same dim problem.
if
hasattr
(
var
.
type
,
"broadcastable"
):
shp
=
[
inp
.
shape
[
i
]
for
i
in
range
(
inp
.
ndim
)
if
not
var
.
type
.
broadcastable
[
i
]]
else
:
shp
=
inp
.
shape
if
len
(
set
(
shp
))
!=
len
(
shp
):
_logger
.
warn
(
"While testing the shape, we received input"
" with dimensions of the same shape
%
s! This"
" lower the quality of the verification."
,
str
(
inp
.
shape
))
break
outputs_function
=
theano
.
function
(
inputs
,
outputs
,
mode
=
mode
)
outputs_function
=
theano
.
function
(
inputs
,
outputs
,
mode
=
mode
)
shapes_function
=
theano
.
function
(
inputs
,
[
o
.
shape
for
o
in
outputs
],
shapes_function
=
theano
.
function
(
inputs
,
[
o
.
shape
for
o
in
outputs
],
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论