Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2766871b
提交
2766871b
authored
3月 03, 2017
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix the gradient tests properly by ensuring the input matrices are
always the product of a matrix with its transpose.
上级
e1180b73
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
17 行增加
和
29 行删除
+17
-29
test_nlinalg.py
theano/tensor/tests/test_nlinalg.py
+7
-9
test_slinalg.py
theano/tensor/tests/test_slinalg.py
+10
-20
没有找到文件。
theano/tensor/tests/test_nlinalg.py
浏览文件 @
2766871b
...
@@ -403,9 +403,9 @@ class test_Eig(utt.InferShapeTester):
...
@@ -403,9 +403,9 @@ class test_Eig(utt.InferShapeTester):
super
(
test_Eig
,
self
)
.
setUp
()
super
(
test_Eig
,
self
)
.
setUp
()
self
.
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
self
.
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
self
.
A
=
theano
.
tensor
.
matrix
(
dtype
=
self
.
dtype
)
self
.
A
=
theano
.
tensor
.
matrix
(
dtype
=
self
.
dtype
)
X
=
numpy
.
asarray
(
self
.
rng
.
rand
(
5
,
5
),
self
.
X
=
numpy
.
asarray
(
self
.
rng
.
rand
(
5
,
5
),
dtype
=
self
.
dtype
)
dtype
=
self
.
dtype
)
self
.
S
=
X
.
dot
(
X
.
T
)
self
.
S
=
self
.
X
.
dot
(
self
.
X
.
T
)
def
test_infer_shape
(
self
):
def
test_infer_shape
(
self
):
A
=
self
.
A
A
=
self
.
A
...
@@ -439,21 +439,19 @@ class test_Eigh(test_Eig):
...
@@ -439,21 +439,19 @@ class test_Eigh(test_Eig):
vl
*
numpy
.
sign
(
vl
[
0
,
:]))
vl
*
numpy
.
sign
(
vl
[
0
,
:]))
def
test_grad
(
self
):
def
test_grad
(
self
):
S
=
self
.
S
X
=
self
.
X
utt
.
verify_grad
(
lambda
x
:
self
.
op
(
x
)[
0
],
[
S
],
rng
=
self
.
rng
)
utt
.
verify_grad
(
lambda
x
:
self
.
op
(
x
.
dot
(
x
.
T
))[
0
],
[
X
],
rng
=
self
.
rng
)
utt
.
verify_grad
(
lambda
x
:
self
.
op
(
x
)[
1
],
[
S
],
rng
=
self
.
rng
,
eps
=
1e-4
)
utt
.
verify_grad
(
lambda
x
:
self
.
op
(
x
.
dot
(
x
.
T
))[
1
],
[
X
],
rng
=
self
.
rng
)
utt
.
verify_grad
(
lambda
x
:
self
.
op
(
x
,
'U'
)[
0
],
[
S
],
rng
=
self
.
rng
)
utt
.
verify_grad
(
lambda
x
:
self
.
op
(
x
.
dot
(
x
.
T
),
'U'
)[
0
],
[
X
],
rng
=
self
.
rng
)
utt
.
verify_grad
(
lambda
x
:
self
.
op
(
x
,
'U'
)[
1
],
[
S
],
rng
=
self
.
rng
,
eps
=
1e-4
)
utt
.
verify_grad
(
lambda
x
:
self
.
op
(
x
.
dot
(
x
.
T
),
'U'
)[
1
],
[
X
],
rng
=
self
.
rng
)
class
test_Eigh_float32
(
test_Eigh
):
class
test_Eigh_float32
(
test_Eigh
):
dtype
=
'float32'
dtype
=
'float32'
@utt.AttemptManyTimes
(
n_attempts
=
3
,
n_req_successes
=
2
)
def
test_uplo
(
self
):
def
test_uplo
(
self
):
super
(
test_Eigh_float32
,
self
)
.
test_uplo
()
super
(
test_Eigh_float32
,
self
)
.
test_uplo
()
@utt.AttemptManyTimes
(
n_attempts
=
3
,
n_req_successes
=
2
)
def
test_grad
(
self
):
def
test_grad
(
self
):
super
(
test_Eigh_float32
,
self
)
.
test_grad
()
super
(
test_Eigh_float32
,
self
)
.
test_grad
()
...
...
theano/tensor/tests/test_slinalg.py
浏览文件 @
2766871b
...
@@ -15,16 +15,9 @@ from theano.tensor.basic import _allclose
...
@@ -15,16 +15,9 @@ from theano.tensor.basic import _allclose
from
theano.tests.test_rop
import
break_op
from
theano.tests.test_rop
import
break_op
from
theano.tests
import
unittest_tools
as
utt
from
theano.tests
import
unittest_tools
as
utt
from
theano
import
config
from
theano
import
config
from
theano.tensor.slinalg
import
(
Cholesky
,
from
theano.tensor.slinalg
import
(
cholesky
,
Cholesky
,
cholesky
,
CholeskyGrad
,
Solve
,
solve
,
CholeskyGrad
,
Eigvalsh
,
EigvalshGrad
,
eigvalsh
,
expm
,
kron
)
Solve
,
solve
,
Eigvalsh
,
EigvalshGrad
,
eigvalsh
,
expm
,
kron
)
from
theano.tests.unittest_tools
import
attr
from
theano.tests.unittest_tools
import
attr
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
...
@@ -80,19 +73,16 @@ def test_cholesky_grad():
...
@@ -80,19 +73,16 @@ def test_cholesky_grad():
if
not
imported_scipy
:
if
not
imported_scipy
:
raise
SkipTest
(
"Scipy needed for the Cholesky op."
)
raise
SkipTest
(
"Scipy needed for the Cholesky op."
)
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
r
=
rng
.
rand
(
5
,
5
)
.
astype
(
config
.
floatX
)
r
=
rng
.
randn
(
5
,
5
)
.
astype
(
config
.
floatX
)
pd
=
numpy
.
dot
(
r
,
r
.
T
)
eps
=
None
if
config
.
floatX
==
"float64"
:
eps
=
2e-8
# Check the default.
# Check the default.
yield
(
lambda
:
utt
.
verify_grad
(
cholesky
,
[
pd
],
3
,
rng
,
eps
=
eps
))
yield
(
lambda
:
utt
.
verify_grad
(
lambda
r
:
cholesky
(
r
.
dot
(
r
.
T
)),
[
r
],
3
,
rng
))
# Explicit lower-triangular.
# Explicit lower-triangular.
yield
(
lambda
:
utt
.
verify_grad
(
Cholesky
(
lower
=
True
),
[
pd
],
3
,
yield
(
lambda
:
utt
.
verify_grad
(
lambda
r
:
Cholesky
(
lower
=
True
)(
r
.
dot
(
r
.
T
))
,
rng
,
eps
=
eps
))
[
r
],
3
,
rng
))
# Explicit upper-triangular.
# Explicit upper-triangular.
yield
(
lambda
:
utt
.
verify_grad
(
Cholesky
(
lower
=
False
),
[
pd
],
3
,
yield
(
lambda
:
utt
.
verify_grad
(
lambda
r
:
Cholesky
(
lower
=
False
)(
r
.
dot
(
r
.
T
))
,
rng
,
eps
=
eps
))
[
r
],
3
,
rng
))
@attr
(
'slow'
)
@attr
(
'slow'
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论