Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
41ebb2de
提交
41ebb2de
authored
6月 06, 2014
作者:
Tanjay94
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removed unnecessary A_Xinv_B function.
上级
cd8c9c69
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
1 行增加
和
67 行删除
+1
-67
ops.py
theano/sandbox/linalg/ops.py
+0
-30
test_linalg.py
theano/sandbox/linalg/tests/test_linalg.py
+1
-37
没有找到文件。
theano/sandbox/linalg/ops.py
浏览文件 @
41ebb2de
...
@@ -863,36 +863,6 @@ def spectral_radius_bound(X, log2_exponent):
...
@@ -863,36 +863,6 @@ def spectral_radius_bound(X, log2_exponent):
2
**
(
-
log2_exponent
))
2
**
(
-
log2_exponent
))
class
A_Xinv_b
(
Op
):
"""Product of form a inv(X) b"""
def
make_node
(
self
,
a
,
X
,
b
):
assert
imported_scipy
,
(
"Scipy not available. Scipy is needed for the A_Xinv_b op"
)
a
=
as_tensor_variable
(
a
)
X
=
as_tensor_variable
(
X
)
b
=
as_tensor_variable
(
b
)
assert
a
.
ndim
==
2
assert
X
.
ndim
==
2
assert
b
.
ndim
==
2
o
=
theano
.
tensor
.
matrix
(
dtype
=
X
.
dtype
)
return
Apply
(
self
,
[
a
,
X
,
b
],
[
o
])
def
perform
(
self
,
ndoe
,
inputs
,
outstor
):
a
,
X
,
b
=
inputs
iX
=
numpy
.
linalg
.
inv
(
X
)
z
=
numpy
.
dot
(
numpy
.
dot
(
a
,
iX
),
b
)
outstor
[
0
][
0
]
=
z
def
grad
(
self
,
inputs
,
g_outputs
):
gz
,
=
g_outputs
a
,
X
,
b
=
inputs
iX
=
matrix_inverse
(
X
)
ga
=
matrix_dot
(
gz
,
b
.
T
,
iX
.
T
)
gX
=
-
matrix_dot
(
iX
.
T
,
a
,
gz
,
b
.
T
,
iX
.
T
)
gb
=
matrix_dot
(
iX
.
T
,
a
.
T
,
gz
)
return
[
ga
,
gX
,
gb
]
class
Eig
(
Op
):
class
Eig
(
Op
):
"""Compute the eigenvalues and right eigenvectors of a square array.
"""Compute the eigenvalues and right eigenvectors of a square array.
...
...
theano/sandbox/linalg/tests/test_linalg.py
浏览文件 @
41ebb2de
...
@@ -33,7 +33,7 @@ from theano.sandbox.linalg.ops import (cholesky,
...
@@ -33,7 +33,7 @@ from theano.sandbox.linalg.ops import (cholesky,
imported_scipy
,
imported_scipy
,
Eig
,
Eig
,
inv_as_solve
,
inv_as_solve
,
A_Xinv_
b
A_Xinv_
B
)
)
from
theano.sandbox.linalg
import
eig
,
eigh
,
eigvalsh
from
theano.sandbox.linalg
import
eig
,
eigh
,
eigvalsh
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
...
@@ -674,39 +674,3 @@ def test_eigvalsh_grad():
...
@@ -674,39 +674,3 @@ def test_eigvalsh_grad():
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
:
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
)
class
test_A_Xinv_b
():
def
test_A_Xinv_b
(
self
):
x
=
tensor
.
matrix
()
y
=
tensor
.
matrix
()
z
=
tensor
.
matrix
()
m
=
A_Xinv_b
()(
x
,
y
,
z
)
f
=
function
([
x
,
y
,
z
],
m
)
X
=
[[
1
,
1
],
[
1
,
1
]]
Y
=
[[
2
,
1
],
[
3
,
4
]]
Z
=
[[
1
,
1
],
[
1
,
1
]]
assert
numpy
.
allclose
(
f
(
X
,
Y
,
Z
),
[[
0.4
,
0.4
],
[
0.4
,
0.4
]])
def
test_shape_conflict
(
self
):
x
=
tensor
.
matrix
()
y
=
tensor
.
matrix
()
z
=
tensor
.
matrix
()
m
=
A_Xinv_b
()(
x
,
y
,
z
)
f
=
function
([
x
,
y
,
z
],
m
)
X
=
[[
1
,
1
,
1
],
[
1
,
1
,
1
]]
Y
=
[[
2
,
-
9
],
[
3
,
4
]]
Z
=
[[
1
,
1
],
[
1
,
1
]]
assert_raises
(
ValueError
,
f
,
X
,
Y
,
Z
)
def
test_grad
(
self
):
x
=
tensor
.
matrix
()
y
=
tensor
.
matrix
()
z
=
tensor
.
matrix
()
m
=
A_Xinv_b
()(
x
,
y
,
z
)
f
=
function
([
x
,
y
,
z
],
m
)
X
=
numpy
.
asarray
([[
1
,
1
],
[
1
,
1
]],
dtype
=
'float32'
)
Y
=
numpy
.
asarray
([[
2
,
1
],
[
3
,
4
]],
dtype
=
'float32'
)
Z
=
numpy
.
asarray
([[
1
,
1
],
[
1
,
1
]],
dtype
=
'float32'
)
theano
.
tests
.
unittest_tools
.
verify_grad
(
A_Xinv_b
(),
[
X
,
Y
,
Z
])
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论