Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3127e645
提交
3127e645
authored
7月 08, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pep8
上级
8dabd398
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
17 行增加
和
13 行删除
+17
-13
test_basic.py
theano/sparse/tests/test_basic.py
+17
-13
没有找到文件。
theano/sparse/tests/test_basic.py
浏览文件 @
3127e645
...
@@ -17,7 +17,7 @@ from theano.sparse import enable_sparse
...
@@ -17,7 +17,7 @@ from theano.sparse import enable_sparse
from
theano.gof.python25
import
all
,
any
,
product
from
theano.gof.python25
import
all
,
any
,
product
if
enable_sparse
==
Fal
se
:
if
not
enable_spar
se
:
raise
SkipTest
(
'Optional package sparse disabled'
)
raise
SkipTest
(
'Optional package sparse disabled'
)
from
theano.sparse.basic
import
_is_dense
,
_is_sparse
,
_mtypes
from
theano.sparse.basic
import
_is_dense
,
_is_sparse
,
_mtypes
...
@@ -399,7 +399,6 @@ class SparseInferShapeTester(utt.InferShapeTester):
...
@@ -399,7 +399,6 @@ class SparseInferShapeTester(utt.InferShapeTester):
[
csc_from_dense
(
x
)],
[
csc_from_dense
(
x
)],
[
numpy
.
random
.
randn
(
10
,
40
)
.
astype
(
[
numpy
.
random
.
randn
(
10
,
40
)
.
astype
(
config
.
floatX
)],
config
.
floatX
)],
csc_from_dense
.
__class__
)
csc_from_dense
.
__class__
)
def
test_sparse_from_list
(
self
):
def
test_sparse_from_list
(
self
):
...
@@ -789,7 +788,8 @@ class test_csm(unittest.TestCase):
...
@@ -789,7 +788,8 @@ class test_csm(unittest.TestCase):
numpy
.
asarray
(
spmat
.
shape
,
'int32'
))
numpy
.
asarray
(
spmat
.
shape
,
'int32'
))
col1
=
sp_types
[
format
]((
res
,
spmat
.
indices
,
spmat
.
indptr
),
col1
=
sp_types
[
format
]((
res
,
spmat
.
indices
,
spmat
.
indptr
),
shape
=
numpy
.
asarray
(
spmat
.
shape
,
'int32'
))[:,
1
]
.
data
shape
=
numpy
.
asarray
(
spmat
.
shape
,
'int32'
))[:,
1
]
.
data
assert
numpy
.
all
(
col1
==
2
)
assert
numpy
.
all
(
col1
==
2
)
...
@@ -909,8 +909,7 @@ class test_structureddot(unittest.TestCase):
...
@@ -909,8 +909,7 @@ class test_structureddot(unittest.TestCase):
spmat
=
sp
.
csc_matrix
(
spmat
)
spmat
=
sp
.
csc_matrix
(
spmat
)
images
=
tensor
.
Tensor
(
dtype
=
'float32'
,
images
=
tensor
.
Tensor
(
dtype
=
'float32'
,
broadcastable
=
[
False
,
False
])(
broadcastable
=
[
False
,
False
])(
'images'
)
'images'
)
cscmat
=
CSC
(
kerns
,
spmat
.
indices
[:
spmat
.
size
],
cscmat
=
CSC
(
kerns
,
spmat
.
indices
[:
spmat
.
size
],
spmat
.
indptr
,
spmat
.
shape
)
spmat
.
indptr
,
spmat
.
shape
)
...
@@ -931,7 +930,8 @@ class test_structureddot(unittest.TestCase):
...
@@ -931,7 +930,8 @@ class test_structureddot(unittest.TestCase):
#print 'type of kernvals = ', kernvals.dtype
#print 'type of kernvals = ', kernvals.dtype
bsize
=
3
bsize
=
3
imvals
=
1.0
*
numpy
.
array
(
numpy
.
arange
(
bsize
*
spmat
.
shape
[
1
])
.
\
imvals
=
1.0
*
numpy
.
array
(
numpy
.
arange
(
bsize
*
spmat
.
shape
[
1
])
.
\
reshape
(
bsize
,
spmat
.
shape
[
1
]),
dtype
=
'float32'
)
reshape
(
bsize
,
spmat
.
shape
[
1
]),
dtype
=
'float32'
)
outvals
=
f
(
kernvals
,
imvals
)
outvals
=
f
(
kernvals
,
imvals
)
#print outvals
#print outvals
...
@@ -1281,7 +1281,7 @@ class UsmmTests(unittest.TestCase):
...
@@ -1281,7 +1281,7 @@ class UsmmTests(unittest.TestCase):
for
node
in
topo
])
==
len
(
topo
)
-
5
)
for
node
in
topo
])
==
len
(
topo
)
-
5
)
new_topo
=
[]
new_topo
=
[]
for
node
in
topo
:
for
node
in
topo
:
if
not
(
isinstance
(
node
.
op
,
tensor
.
Elemwise
)
and
\
if
not
(
isinstance
(
node
.
op
,
tensor
.
Elemwise
)
and
isinstance
(
node
.
op
.
scalar_op
,
isinstance
(
node
.
op
.
scalar_op
,
theano
.
scalar
.
basic
.
Cast
)):
theano
.
scalar
.
basic
.
Cast
)):
new_topo
.
append
(
node
)
new_topo
.
append
(
node
)
...
@@ -1571,7 +1571,7 @@ class SpSumTester(utt.InferShapeTester):
...
@@ -1571,7 +1571,7 @@ class SpSumTester(utt.InferShapeTester):
shape
=
(
10
,
10
))
shape
=
(
10
,
10
))
z
=
theano
.
sparse
.
sp_sum
(
variable
[
0
],
axis
=
axis
)
z
=
theano
.
sparse
.
sp_sum
(
variable
[
0
],
axis
=
axis
)
if
axis
==
None
:
if
axis
is
None
:
assert
z
.
type
.
broadcastable
==
()
assert
z
.
type
.
broadcastable
==
()
else
:
else
:
assert
z
.
type
.
broadcastable
==
(
False
,
)
assert
z
.
type
.
broadcastable
==
(
False
,
)
...
@@ -1962,13 +1962,15 @@ class Test_getitem(unittest.TestCase):
...
@@ -1962,13 +1962,15 @@ class Test_getitem(unittest.TestCase):
# Advanced indexing is not supported
# Advanced indexing is not supported
self
.
assertRaises
(
ValueError
,
self
.
assertRaises
(
ValueError
,
x
.
__getitem__
,
(
tensor
.
ivector
(
'l'
),
slice
(
a
,
b
)))
x
.
__getitem__
,
(
tensor
.
ivector
(
'l'
),
slice
(
a
,
b
)))
# Indexing with random things is not supported either
# Indexing with random things is not supported either
self
.
assertRaises
(
ValueError
,
self
.
assertRaises
(
ValueError
,
x
.
__getitem__
,
slice
(
tensor
.
fscalar
(
'f'
),
None
))
x
.
__getitem__
,
slice
(
tensor
.
fscalar
(
'f'
),
None
))
self
.
assertRaises
(
ValueError
,
self
.
assertRaises
(
ValueError
,
x
.
__getitem__
,
(
slice
(
None
),
slice
([
1
,
3
,
4
],
None
)))
x
.
__getitem__
,
(
slice
(
None
),
slice
([
1
,
3
,
4
],
None
)))
def
test_GetItemScalar
(
self
):
def
test_GetItemScalar
(
self
):
sparse_formats
=
(
'csc'
,
'csr'
)
sparse_formats
=
(
'csc'
,
'csr'
)
...
@@ -2558,7 +2560,8 @@ class MulSVTester(unittest.TestCase):
...
@@ -2558,7 +2560,8 @@ class MulSVTester(unittest.TestCase):
mat
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
3
),
dtype
=
dtype
)
mat
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
3
),
dtype
=
dtype
)
theano
.
sparse
.
verify_grad_sparse
(
mul_s_v
,
theano
.
sparse
.
verify_grad_sparse
(
mul_s_v
,
[
spmat
,
mat
],
structured
=
True
)
[
spmat
,
mat
],
structured
=
True
)
def
test_mul_s_v
(
self
):
def
test_mul_s_v
(
self
):
sp_types
=
{
'csc'
:
sp
.
csc_matrix
,
sp_types
=
{
'csc'
:
sp
.
csc_matrix
,
...
@@ -2592,7 +2595,8 @@ class StructuredAddSVTester(unittest.TestCase):
...
@@ -2592,7 +2595,8 @@ class StructuredAddSVTester(unittest.TestCase):
mat
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
3
),
dtype
=
dtype
)
mat
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
3
),
dtype
=
dtype
)
theano
.
sparse
.
verify_grad_sparse
(
structured_add_s_v
,
theano
.
sparse
.
verify_grad_sparse
(
structured_add_s_v
,
[
spmat
,
mat
],
structured
=
True
)
[
spmat
,
mat
],
structured
=
True
)
def
test_structured_add_s_v
(
self
):
def
test_structured_add_s_v
(
self
):
sp_types
=
{
'csc'
:
sp
.
csc_matrix
,
sp_types
=
{
'csc'
:
sp
.
csc_matrix
,
...
@@ -2674,7 +2678,7 @@ test_shared_options = theano.tensor.tests.test_sharedvar.makeSharedTester(
...
@@ -2674,7 +2678,7 @@ test_shared_options = theano.tensor.tests.test_sharedvar.makeSharedTester(
ref_fct_
=
lambda
a
:
numpy
.
asarray
((
a
*
2
)
.
todense
()),
ref_fct_
=
lambda
a
:
numpy
.
asarray
((
a
*
2
)
.
todense
()),
cast_value_
=
scipy
.
sparse
.
csr_matrix
,
cast_value_
=
scipy
.
sparse
.
csr_matrix
,
name
=
'test_shared_options'
,
name
=
'test_shared_options'
,
)
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论