Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
fdc7c1f4
提交
fdc7c1f4
authored
3月 10, 2015
作者:
Pierre Luc Carrier
提交者:
Arnaud Bergeron
3月 13, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move tests for kron fron sandbox/tests/test_kron.py to theano.tensor.tests.test_slinalg.py
上级
dcbe40c8
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
44 行增加
和
66 行删除
+44
-66
test_kron.py
theano/sandbox/linalg/tests/test_kron.py
+0
-64
test_slinalg.py
theano/tensor/tests/test_slinalg.py
+44
-2
没有找到文件。
theano/sandbox/linalg/tests/test_kron.py
deleted
100644 → 0
浏览文件 @
dcbe40c8
from
nose.plugins.skip
import
SkipTest
import
numpy
import
theano
from
theano
import
tensor
,
function
from
theano.tests
import
unittest_tools
as
utt
from
theano.sandbox.linalg.kron
import
kron
floatX
=
theano
.
config
.
floatX
try
:
import
scipy.linalg
imported_scipy
=
True
except
ImportError
:
imported_scipy
=
False
class
TestKron
(
utt
.
InferShapeTester
):
rng
=
numpy
.
random
.
RandomState
(
43
)
def
setUp
(
self
):
super
(
TestKron
,
self
)
.
setUp
()
self
.
op
=
kron
def
test_perform
(
self
):
if
not
imported_scipy
:
raise
SkipTest
(
'kron tests need the scipy package to be installed'
)
for
shp0
in
[(
2
,),
(
2
,
3
),
(
2
,
3
,
4
),
(
2
,
3
,
4
,
5
)]:
for
shp1
in
[(
6
,),
(
6
,
7
),
(
6
,
7
,
8
),
(
6
,
7
,
8
,
9
)]:
if
len
(
shp0
)
+
len
(
shp1
)
==
2
:
continue
x
=
tensor
.
tensor
(
dtype
=
'floatX'
,
broadcastable
=
(
False
,)
*
len
(
shp0
))
y
=
tensor
.
tensor
(
dtype
=
'floatX'
,
broadcastable
=
(
False
,)
*
len
(
shp1
))
f
=
function
([
x
,
y
],
kron
(
x
,
y
))
a
=
numpy
.
asarray
(
self
.
rng
.
rand
(
*
shp0
))
.
astype
(
floatX
)
b
=
self
.
rng
.
rand
(
*
shp1
)
.
astype
(
floatX
)
out
=
f
(
a
,
b
)
assert
numpy
.
allclose
(
out
,
scipy
.
linalg
.
kron
(
a
,
b
))
def
test_numpy_2d
(
self
):
for
shp0
in
[(
2
,
3
)]:
for
shp1
in
[(
6
,
7
)]:
if
len
(
shp0
)
+
len
(
shp1
)
==
2
:
continue
x
=
tensor
.
tensor
(
dtype
=
'floatX'
,
broadcastable
=
(
False
,)
*
len
(
shp0
))
y
=
tensor
.
tensor
(
dtype
=
'floatX'
,
broadcastable
=
(
False
,)
*
len
(
shp1
))
f
=
function
([
x
,
y
],
kron
(
x
,
y
))
a
=
numpy
.
asarray
(
self
.
rng
.
rand
(
*
shp0
))
.
astype
(
floatX
)
b
=
self
.
rng
.
rand
(
*
shp1
)
.
astype
(
floatX
)
out
=
f
(
a
,
b
)
assert
numpy
.
allclose
(
out
,
numpy
.
kron
(
a
,
b
))
if
__name__
==
"__main__"
:
t
=
TestKron
(
'setUp'
)
t
.
setUp
()
t
.
test_perform
()
t
.
test_infer_shape
()
theano/tensor/tests/test_slinalg.py
浏览文件 @
fdc7c1f4
...
...
@@ -21,8 +21,8 @@ from theano.tensor.slinalg import ( Cholesky,
Eigvalsh
,
EigvalshGrad
,
eigvalsh
,
expm
)
expm
,
kron
)
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.attrib
import
attr
...
...
@@ -281,3 +281,45 @@ def test_expm_grad_3():
A
=
rng
.
randn
(
5
,
5
)
tensor
.
verify_grad
(
expm
,
[
A
],
rng
=
rng
)
class
TestKron
(
utt
.
InferShapeTester
):
rng
=
numpy
.
random
.
RandomState
(
43
)
def
setUp
(
self
):
super
(
TestKron
,
self
)
.
setUp
()
self
.
op
=
kron
def
test_perform
(
self
):
if
not
imported_scipy
:
raise
SkipTest
(
'kron tests need the scipy package to be installed'
)
for
shp0
in
[(
2
,),
(
2
,
3
),
(
2
,
3
,
4
),
(
2
,
3
,
4
,
5
)]:
for
shp1
in
[(
6
,),
(
6
,
7
),
(
6
,
7
,
8
),
(
6
,
7
,
8
,
9
)]:
if
len
(
shp0
)
+
len
(
shp1
)
==
2
:
continue
x
=
tensor
.
tensor
(
dtype
=
'floatX'
,
broadcastable
=
(
False
,)
*
len
(
shp0
))
y
=
tensor
.
tensor
(
dtype
=
'floatX'
,
broadcastable
=
(
False
,)
*
len
(
shp1
))
f
=
function
([
x
,
y
],
kron
(
x
,
y
))
a
=
numpy
.
asarray
(
self
.
rng
.
rand
(
*
shp0
))
.
astype
(
config
.
floatX
)
b
=
self
.
rng
.
rand
(
*
shp1
)
.
astype
(
config
.
floatX
)
out
=
f
(
a
,
b
)
assert
numpy
.
allclose
(
out
,
scipy
.
linalg
.
kron
(
a
,
b
))
def
test_numpy_2d
(
self
):
for
shp0
in
[(
2
,
3
)]:
for
shp1
in
[(
6
,
7
)]:
if
len
(
shp0
)
+
len
(
shp1
)
==
2
:
continue
x
=
tensor
.
tensor
(
dtype
=
'floatX'
,
broadcastable
=
(
False
,)
*
len
(
shp0
))
y
=
tensor
.
tensor
(
dtype
=
'floatX'
,
broadcastable
=
(
False
,)
*
len
(
shp1
))
f
=
function
([
x
,
y
],
kron
(
x
,
y
))
a
=
numpy
.
asarray
(
self
.
rng
.
rand
(
*
shp0
))
.
astype
(
config
.
floatX
)
b
=
self
.
rng
.
rand
(
*
shp1
)
.
astype
(
config
.
floatX
)
out
=
f
(
a
,
b
)
assert
numpy
.
allclose
(
out
,
numpy
.
kron
(
a
,
b
))
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论