Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d26ae898
提交
d26ae898
authored
5月 09, 2014
作者:
Robert McGibbon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change name to eigvalsh
上级
4cda7c7e
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
15 行增加
和
16 行删除
+15
-16
__init__.py
theano/sandbox/linalg/__init__.py
+1
-1
ops.py
theano/sandbox/linalg/ops.py
+5
-5
test_linalg.py
theano/sandbox/linalg/tests/test_linalg.py
+9
-10
没有找到文件。
theano/sandbox/linalg/__init__.py
浏览文件 @
d26ae898
...
@@ -2,5 +2,5 @@
...
@@ -2,5 +2,5 @@
from
kron
import
kron
from
kron
import
kron
from
ops
import
(
cholesky
,
matrix_inverse
,
solve
,
from
ops
import
(
cholesky
,
matrix_inverse
,
solve
,
diag
,
extract_diag
,
alloc_diag
,
diag
,
extract_diag
,
alloc_diag
,
det
,
psd
,
eig
,
eigh
,
g
eigvalsh
,
det
,
psd
,
eig
,
eigh
,
eigvalsh
,
trace
,
spectral_radius_bound
)
trace
,
spectral_radius_bound
)
theano/sandbox/linalg/ops.py
浏览文件 @
d26ae898
...
@@ -1099,7 +1099,7 @@ class EighGrad(Op):
...
@@ -1099,7 +1099,7 @@ class EighGrad(Op):
return
[
shapes
[
0
]]
return
[
shapes
[
0
]]
class
G
Eigvalsh
(
Op
):
class
Eigvalsh
(
Op
):
"""Generalized eigenvalues of a Hermetian positive definite eigensystem
"""Generalized eigenvalues of a Hermetian positive definite eigensystem
"""
"""
...
@@ -1133,14 +1133,14 @@ class GEigvalsh(Op):
...
@@ -1133,14 +1133,14 @@ class GEigvalsh(Op):
def
grad
(
self
,
inputs
,
g_outputs
):
def
grad
(
self
,
inputs
,
g_outputs
):
a
,
b
=
inputs
a
,
b
=
inputs
gw
,
=
g_outputs
gw
,
=
g_outputs
return
G
EigvalshGrad
(
self
.
lower
)(
a
,
b
,
gw
)
return
EigvalshGrad
(
self
.
lower
)(
a
,
b
,
gw
)
def
infer_shape
(
self
,
node
,
shapes
):
def
infer_shape
(
self
,
node
,
shapes
):
n
=
shapes
[
0
][
0
]
n
=
shapes
[
0
][
0
]
return
[(
n
,)]
return
[(
n
,)]
class
G
EigvalshGrad
(
Op
):
class
EigvalshGrad
(
Op
):
"""Gradient of generalized eigenvalues of a Hermetian positive definite
"""Gradient of generalized eigenvalues of a Hermetian positive definite
eigensystem
eigensystem
"""
"""
...
@@ -1192,5 +1192,5 @@ class GEigvalshGrad(Op):
...
@@ -1192,5 +1192,5 @@ class GEigvalshGrad(Op):
return
[
shapes
[
0
],
shapes
[
1
]]
return
[
shapes
[
0
],
shapes
[
1
]]
def
g
eigvalsh
(
a
,
b
,
lower
=
True
):
def
eigvalsh
(
a
,
b
,
lower
=
True
):
return
G
Eigvalsh
(
lower
)(
a
,
b
)
return
Eigvalsh
(
lower
)(
a
,
b
)
theano/sandbox/linalg/tests/test_linalg.py
浏览文件 @
d26ae898
...
@@ -32,7 +32,7 @@ from theano.sandbox.linalg.ops import (cholesky,
...
@@ -32,7 +32,7 @@ from theano.sandbox.linalg.ops import (cholesky,
Eig
,
Eig
,
inv_as_solve
,
inv_as_solve
,
)
)
from
theano.sandbox.linalg
import
eig
,
eigh
,
g
eigvalsh
from
theano.sandbox.linalg
import
eig
,
eigh
,
eigvalsh
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.attrib
import
attr
from
nose.plugins.attrib
import
attr
...
@@ -575,29 +575,28 @@ def test_matrix_inverse_solve():
...
@@ -575,29 +575,28 @@ def test_matrix_inverse_solve():
assert
isinstance
(
out
.
owner
.
op
,
Solve
)
assert
isinstance
(
out
.
owner
.
op
,
Solve
)
def
test_
g
eigvalsh
():
def
test_eigvalsh
():
if
not
imported_scipy
:
if
not
imported_scipy
:
raise
SkipTest
(
"Scipy needed for the geigvalsh op."
)
raise
SkipTest
(
"Scipy needed for the geigvalsh op."
)
import
scipy.linalg
import
scipy.linalg
A
=
theano
.
tensor
.
dmatrix
(
'a'
)
A
=
theano
.
tensor
.
dmatrix
(
'a'
)
B
=
theano
.
tensor
.
dmatrix
(
'b'
)
B
=
theano
.
tensor
.
dmatrix
(
'b'
)
f
=
function
([
A
,
B
],
g
eigvalsh
(
A
,
B
))
f
=
function
([
A
,
B
],
eigvalsh
(
A
,
B
))
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
a
=
rng
.
randn
(
5
,
5
)
a
=
rng
.
randn
(
5
,
5
)
a
=
a
+
a
.
T
a
=
a
+
a
.
T
b
=
10
*
numpy
.
eye
(
5
,
5
)
+
rng
.
randn
(
5
,
5
)
for
b
in
[
10
*
numpy
.
eye
(
5
,
5
)
+
rng
.
randn
(
5
,
5
),
None
]:
w
=
f
(
a
,
b
)
w
=
f
(
a
,
b
)
refw
=
scipy
.
linalg
.
eigvalsh
(
a
,
b
)
refw
=
scipy
.
linalg
.
eigvalsh
(
a
,
b
)
numpy
.
testing
.
assert_array_almost_equal
(
w
,
refw
)
numpy
.
testing
.
assert_array_almost_equal
(
w
,
refw
)
def
test_
g
eigvalsh_grad
():
def
test_eigvalsh_grad
():
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
a
=
rng
.
randn
(
5
,
5
)
a
=
rng
.
randn
(
5
,
5
)
a
=
a
+
a
.
T
a
=
a
+
a
.
T
b
=
10
*
numpy
.
eye
(
5
,
5
)
+
rng
.
randn
(
5
,
5
)
b
=
10
*
numpy
.
eye
(
5
,
5
)
+
rng
.
randn
(
5
,
5
)
tensor
.
verify_grad
(
lambda
a
,
b
:
g
eigvalsh
(
a
,
b
)
.
dot
([
1
,
2
,
3
,
4
,
5
]),
tensor
.
verify_grad
(
lambda
a
,
b
:
eigvalsh
(
a
,
b
)
.
dot
([
1
,
2
,
3
,
4
,
5
]),
[
a
,
b
],
rng
=
numpy
.
random
)
[
a
,
b
],
rng
=
numpy
.
random
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论