Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e7204ea2
提交
e7204ea2
authored
6月 02, 2014
作者:
Tanjay94
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed norm test to include outdated numpy version.
上级
0c737bad
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
49 行增加
和
24 行删除
+49
-24
test_linalg.py
theano/sandbox/linalg/tests/test_linalg.py
+49
-24
没有找到文件。
theano/sandbox/linalg/tests/test_linalg.py
浏览文件 @
e7204ea2
...
@@ -4,6 +4,7 @@ import numpy
...
@@ -4,6 +4,7 @@ import numpy
import
numpy.linalg
import
numpy.linalg
from
numpy.testing
import
assert_array_almost_equal
from
numpy.testing
import
assert_array_almost_equal
from
numpy.testing
import
dec
,
assert_array_equal
,
assert_allclose
from
numpy.testing
import
dec
,
assert_array_equal
,
assert_allclose
from
nose.plugins.skip
import
SkipTest
import
theano
import
theano
from
theano
import
tensor
,
function
from
theano
import
tensor
,
function
...
@@ -636,30 +637,54 @@ class Matrix_power():
...
@@ -636,30 +637,54 @@ class Matrix_power():
self
.
assertRaises
(
ValueError
,
f
,
a
)
self
.
assertRaises
(
ValueError
,
f
,
a
)
class
T_NormTests
(
unittest
.
TestCase
):
class
T_NormTests
(
unittest
.
TestCase
):
def
test_wrong_type_of_ord_for_vector
(
self
):
try
:
self
.
assertRaises
(
ValueError
,
norm
,
[
2
,
1
],
'fro'
,
0
)
def
test_wrong_type_of_ord_for_vector
(
self
):
def
test_wrong_type_of_ord_for_vector_in_matrix
(
self
):
self
.
assertRaises
(
ValueError
,
norm
,
[
2
,
1
],
'fro'
,
0
)
self
.
assertRaises
(
ValueError
,
norm
,
[[
2
,
1
],[
3
,
4
]],
'fro'
,
0
)
except
TypeError
:
def
test_wrong_type_of_ord_for_vector_in_tensor
(
self
):
raise
SkipTest
(
'Your numpy version is outdated.'
)
self
.
assertRaises
(
ValueError
,
norm
,
[[[
2
,
1
],[
3
,
4
]],[[
6
,
5
],[
7
,
8
]]],
'fro'
,
0
)
try
:
def
test_wrong_type_of_ord_for_matrix
(
self
):
def
test_wrong_type_of_ord_for_vector_in_matrix
(
self
):
self
.
assertRaises
(
ValueError
,
norm
,
[[
2
,
1
],[
3
,
4
]],
0
,
None
)
self
.
assertRaises
(
ValueError
,
norm
,
[[
2
,
1
],[
3
,
4
]],
'fro'
,
0
)
def
test_wrong_type_of_ord_for_matrix_in_tensor
(
self
):
except
TypeError
:
self
.
assertRaises
(
ValueError
,
norm
,
[[[
2
,
1
],[
3
,
4
]],[[
6
,
5
],[
7
,
8
]]],
0
,
None
)
raise
SkipTest
(
'Your numpy version is outdated.'
)
def
test_non_tensorial_input
(
self
):
try
:
self
.
assertRaises
(
ValueError
,
norm
,
3
,
None
,
None
)
def
test_wrong_type_of_ord_for_vector_in_tensor
(
self
):
def
test_no_enough_dimensions
(
self
):
self
.
assertRaises
(
ValueError
,
norm
,
[[[
2
,
1
],[
3
,
4
]],[[
6
,
5
],[
7
,
8
]]],
'fro'
,
0
)
self
.
assertRaises
(
ValueError
,
norm
,
[[
2
,
1
],[
3
,
4
]],
None
,
3
)
except
TypeError
:
def
test_numpy_compare
(
self
):
raise
SkipTest
(
'Your numpy version is outdated.'
)
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
try
:
A
=
tensor
.
matrix
(
"A"
,
dtype
=
theano
.
config
.
floatX
)
def
test_wrong_type_of_ord_for_matrix
(
self
):
Q
=
norm
(
A
,
None
,
None
)
self
.
assertRaises
(
ValueError
,
norm
,
[[
2
,
1
],[
3
,
4
]],
0
,
None
)
fn
=
function
([
A
],
[
Q
])
except
TypeError
:
a
=
rng
.
rand
(
4
,
4
)
.
astype
(
theano
.
config
.
floatX
)
raise
SkipTest
(
'Your numpy version is outdated.'
)
try
:
n_n
=
numpy
.
linalg
.
norm
(
a
,
None
,
None
)
def
test_wrong_type_of_ord_for_matrix_in_tensor
(
self
):
t_n
=
fn
(
a
)
self
.
assertRaises
(
ValueError
,
norm
,
[[[
2
,
1
],[
3
,
4
]],[[
6
,
5
],[
7
,
8
]]],
0
,
None
)
assert
_allclose
(
n_n
,
t_n
)
except
TypeError
:
raise
SkipTest
(
'Your numpy version is outdated.'
)
try
:
def
test_non_tensorial_input
(
self
):
self
.
assertRaises
(
ValueError
,
norm
,
3
,
None
,
None
)
except
TypeError
:
raise
SkipTest
(
'Your numpy version is outdated.'
)
try
:
def
test_no_enough_dimensions
(
self
):
self
.
assertRaises
(
ValueError
,
norm
,
[[
2
,
1
],[
3
,
4
]],
None
,
3
)
except
TypeError
:
raise
SkipTest
(
'Your numpy version is outdated.'
)
try
:
def
test_numpy_compare
(
self
):
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
A
=
tensor
.
matrix
(
"A"
,
dtype
=
theano
.
config
.
floatX
)
Q
=
norm
(
A
,
None
,
None
)
fn
=
function
([
A
],
[
Q
])
a
=
rng
.
rand
(
4
,
4
)
.
astype
(
theano
.
config
.
floatX
)
n_n
=
numpy
.
linalg
.
norm
(
a
,
None
,
None
)
t_n
=
fn
(
a
)
assert
_allclose
(
n_n
,
t_n
)
except
TypeError
:
raise
SkipTest
(
'Your numpy version is outdated.'
)
class
T_lstsq
(
unittest
.
TestCase
):
class
T_lstsq
(
unittest
.
TestCase
):
def
test_correct_solution
(
self
):
def
test_correct_solution
(
self
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论