Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ac4b7a5d
提交
ac4b7a5d
authored
11月 07, 2016
作者:
kvmanohar22
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modified numpy imports to one common form
上级
86d21acd
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
21 行增加
和
21 行删除
+21
-21
test_basic.py
theano/sparse/tests/test_basic.py
+0
-0
test_opt.py
theano/sparse/tests/test_opt.py
+4
-4
test_sp2.py
theano/sparse/tests/test_sp2.py
+9
-9
test_utils.py
theano/sparse/tests/test_utils.py
+8
-8
没有找到文件。
theano/sparse/tests/test_basic.py
浏览文件 @
ac4b7a5d
差异被折叠。
点击展开。
theano/sparse/tests/test_opt.py
浏览文件 @
ac4b7a5d
from
__future__
import
absolute_import
,
print_function
,
division
from
nose.plugins.skip
import
SkipTest
import
numpy
import
numpy
as
np
try
:
import
scipy.sparse
as
sp
import
scipy.sparse
...
...
@@ -157,14 +157,14 @@ def test_local_dense_from_sparse_sparse_from_dense():
def
test_sd_csc
():
A
=
sp
.
rand
(
4
,
5
,
density
=
0.60
,
format
=
'csc'
,
dtype
=
n
umpy
.
float32
)
b
=
n
umpy
.
random
.
rand
(
5
,
2
)
.
astype
(
numpy
.
float32
)
A
=
sp
.
rand
(
4
,
5
,
density
=
0.60
,
format
=
'csc'
,
dtype
=
n
p
.
float32
)
b
=
n
p
.
random
.
rand
(
5
,
2
)
.
astype
(
np
.
float32
)
target
=
A
*
b
a_val
=
theano
.
tensor
.
as_tensor_variable
(
A
.
data
)
a_ind
=
theano
.
tensor
.
as_tensor_variable
(
A
.
indices
)
a_ptr
=
theano
.
tensor
.
as_tensor_variable
(
A
.
indptr
)
nrows
=
theano
.
tensor
.
as_tensor_variable
(
n
umpy
.
int32
(
A
.
shape
[
0
]))
nrows
=
theano
.
tensor
.
as_tensor_variable
(
n
p
.
int32
(
A
.
shape
[
0
]))
b
=
theano
.
tensor
.
as_tensor_variable
(
b
)
res
=
theano
.
sparse
.
opt
.
sd_csc
(
a_val
,
a_ind
,
a_ptr
,
nrows
,
b
)
.
eval
()
...
...
theano/sparse/tests/test_sp2.py
浏览文件 @
ac4b7a5d
...
...
@@ -2,7 +2,7 @@ from __future__ import absolute_import, print_function, division
import
unittest
from
nose.plugins.skip
import
SkipTest
import
numpy
import
numpy
as
np
try
:
import
scipy.sparse
as
sp
except
ImportError
:
...
...
@@ -30,7 +30,7 @@ class PoissonTester(utt.InferShapeTester):
for
format
in
sparse
.
sparse_formats
:
variable
=
getattr
(
theano
.
sparse
,
format
+
'_matrix'
)
rand
=
n
umpy
.
array
(
numpy
.
random
.
randint
(
1
,
4
,
size
=
(
3
,
4
))
-
1
,
rand
=
n
p
.
array
(
np
.
random
.
randint
(
1
,
4
,
size
=
(
3
,
4
))
-
1
,
dtype
=
theano
.
config
.
floatX
)
x
[
format
]
=
variable
()
...
...
@@ -50,7 +50,7 @@ class PoissonTester(utt.InferShapeTester):
assert
tested
.
format
==
format
assert
tested
.
dtype
==
self
.
a
[
format
]
.
dtype
assert
n
umpy
.
allclose
(
numpy
.
floor
(
tested
.
data
),
tested
.
data
)
assert
n
p
.
allclose
(
np
.
floor
(
tested
.
data
),
tested
.
data
)
assert
tested
.
shape
==
self
.
a
[
format
]
.
shape
def
test_infer_shape
(
self
):
...
...
@@ -67,7 +67,7 @@ class BinomialTester(utt.InferShapeTester):
shape
=
tensor
.
lvector
()
_n
=
5
_p
=
.
25
_shape
=
n
umpy
.
asarray
([
3
,
5
],
dtype
=
'int64'
)
_shape
=
n
p
.
asarray
([
3
,
5
],
dtype
=
'int64'
)
inputs
=
[
n
,
p
,
shape
]
_inputs
=
[
_n
,
_p
,
_shape
]
...
...
@@ -88,7 +88,7 @@ class BinomialTester(utt.InferShapeTester):
assert
tested
.
shape
==
tuple
(
self
.
_shape
)
assert
tested
.
format
==
sp_format
assert
tested
.
dtype
==
o_type
assert
n
umpy
.
allclose
(
numpy
.
floor
(
tested
.
todense
()),
assert
n
p
.
allclose
(
np
.
floor
(
tested
.
todense
()),
tested
.
todense
())
def
test_infer_shape
(
self
):
...
...
@@ -103,7 +103,7 @@ class BinomialTester(utt.InferShapeTester):
class
MultinomialTester
(
utt
.
InferShapeTester
):
p
=
sparse
.
csr_matrix
()
_p
=
sp
.
csr_matrix
(
n
umpy
.
asarray
([[
0.0
,
0.5
,
0.0
,
0.5
],
_p
=
sp
.
csr_matrix
(
n
p
.
asarray
([[
0.0
,
0.5
,
0.0
,
0.5
],
[
0.1
,
0.2
,
0.3
,
0.4
],
[
0.0
,
1.0
,
0.0
,
0.0
],
[
0.3
,
0.3
,
0.0
,
0.4
]],
...
...
@@ -120,16 +120,16 @@ class MultinomialTester(utt.InferShapeTester):
_n
=
5
tested
=
f
(
self
.
_p
,
_n
)
assert
tested
.
shape
==
self
.
_p
.
shape
assert
n
umpy
.
allclose
(
numpy
.
floor
(
tested
.
todense
()),
tested
.
todense
())
assert
n
p
.
allclose
(
np
.
floor
(
tested
.
todense
()),
tested
.
todense
())
assert
tested
[
2
,
1
]
==
_n
n
=
tensor
.
lvector
()
f
=
theano
.
function
([
self
.
p
,
n
],
multinomial
(
n
,
self
.
p
))
_n
=
n
umpy
.
asarray
([
1
,
2
,
3
,
4
],
dtype
=
'int64'
)
_n
=
n
p
.
asarray
([
1
,
2
,
3
,
4
],
dtype
=
'int64'
)
tested
=
f
(
self
.
_p
,
_n
)
assert
tested
.
shape
==
self
.
_p
.
shape
assert
n
umpy
.
allclose
(
numpy
.
floor
(
tested
.
todense
()),
tested
.
todense
())
assert
n
p
.
allclose
(
np
.
floor
(
tested
.
todense
()),
tested
.
todense
())
assert
tested
[
2
,
1
]
==
_n
[
2
]
def
test_infer_shape
(
self
):
...
...
theano/sparse/tests/test_utils.py
浏览文件 @
ac4b7a5d
from
__future__
import
absolute_import
,
print_function
,
division
from
nose.plugins.skip
import
SkipTest
import
numpy
import
numpy
as
np
import
theano.sparse
if
not
theano
.
sparse
.
enable_sparse
:
raise
SkipTest
(
'Optional package sparse disabled'
)
...
...
@@ -11,21 +11,21 @@ from theano.sparse.tests.test_basic import as_sparse_format
def
test_hash_from_sparse
():
hashs
=
[]
rng
=
n
umpy
.
random
.
rand
(
5
,
5
)
rng
=
n
p
.
random
.
rand
(
5
,
5
)
for
format
in
[
'csc'
,
'csr'
]:
rng
=
as_sparse_format
(
rng
,
format
)
for
data
in
[[[
-
2
]],
[[
-
1
]],
[[
0
]],
[[
1
]],
[[
2
]],
n
umpy
.
zeros
((
1
,
5
)),
numpy
.
zeros
((
1
,
6
)),
n
p
.
zeros
((
1
,
5
)),
np
.
zeros
((
1
,
6
)),
# Data buffer empty but different shapes
# n
umpy.zeros((1, 0)), numpy
.zeros((2, 0)),
# n
p.zeros((1, 0)), np
.zeros((2, 0)),
# Same data buffer and shapes but different strides
n
umpy
.
arange
(
25
)
.
reshape
(
5
,
5
),
n
umpy
.
arange
(
25
)
.
reshape
(
5
,
5
)
.
T
,
n
p
.
arange
(
25
)
.
reshape
(
5
,
5
),
n
p
.
arange
(
25
)
.
reshape
(
5
,
5
)
.
T
,
# Same data buffer, shapes and strides
# but different dtypes
n
umpy
.
zeros
((
5
,
5
),
dtype
=
"uint32"
),
n
umpy
.
zeros
((
5
,
5
),
dtype
=
"int32"
),
n
p
.
zeros
((
5
,
5
),
dtype
=
"uint32"
),
n
p
.
zeros
((
5
,
5
),
dtype
=
"int32"
),
# Test slice
rng
,
rng
[
1
:],
rng
[:
4
],
rng
[
1
:
3
],
# Don't test step as they are not supported by sparse
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论