Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3d8f22b4
提交
3d8f22b4
authored
1月 31, 2012
作者:
Li Yao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pep8 check
上级
70b4f56e
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
14 行增加
和
13 行删除
+14
-13
test_basic.py
theano/sparse/tests/test_basic.py
+14
-13
没有找到文件。
theano/sparse/tests/test_basic.py
浏览文件 @
3d8f22b4
...
...
@@ -929,6 +929,7 @@ def test_size():
y
[
0
,
1
]
=
0
check
()
def
test_GetItem2D
():
sparse_formats
=
(
'csc'
,
'csr'
)
for
format
in
sparse_formats
:
...
...
@@ -944,13 +945,11 @@ def test_GetItem2D():
p
=
10
q
=
15
vx
=
as_sparse_format
(
numpy
.
random
.
binomial
(
1
,
0.5
,
(
100
,
100
)),
format
)
.
astype
(
theano
.
config
.
floatX
)
vx
=
as_sparse_format
(
numpy
.
random
.
binomial
(
1
,
0.5
,
(
100
,
100
)),
format
)
.
astype
(
theano
.
config
.
floatX
)
#mode_no_debug = theano.compile.mode.get_default_mode()
#if isinstance(mode_no_debug, theano.compile.DebugMode):
# mode_no_debug = 'FAST_RUN'
f1
=
theano
.
function
([
x
,
a
,
b
,
c
,
d
],
x
[
a
:
b
,
c
:
d
])
r1
=
f1
(
vx
,
m
,
n
,
p
,
q
)
t1
=
vx
[
m
:
n
,
p
:
q
]
...
...
@@ -959,9 +958,10 @@ def test_GetItem2D():
""""
Important: based on a discussion with both Fred and James
The following indexing methods is not supported because the rval would be a sparse
matrix rather than a sparse vector, which is a deviation from numpy indexing rule.
This decision is made largely for keeping the consistency between numpy and theano.
The following indexing methods is not supported because the rval
would be a sparse matrix rather than a sparse vector, which is a
deviation from numpy indexing rule. This decision is made largely
for keeping the consistency between numpy and theano.
f2 = theano.function([x, a, b, c], x[a:b, c])
r2 = f2(vx, m, n, p)
...
...
@@ -996,26 +996,27 @@ def test_GetItem2D():
#-----------------------------------------------------------
# test cases using int indexing instead of theano variable
f6
=
theano
.
function
([
x
],
x
[
1
:
10
,
10
:
20
])
f6
=
theano
.
function
([
x
],
x
[
1
:
10
,
10
:
20
])
r6
=
f6
(
vx
)
t6
=
vx
[
1
:
10
,
10
:
20
]
t6
=
vx
[
1
:
10
,
10
:
20
]
assert
r6
.
shape
==
t6
.
shape
assert
numpy
.
all
(
r6
.
toarray
()
==
t6
.
toarray
())
#----------------------------------------------------------
# test cases with indexing both with theano variable and int
f8
=
theano
.
function
([
x
,
a
,
b
],
x
[
a
:
b
,
10
:
20
])
f8
=
theano
.
function
([
x
,
a
,
b
],
x
[
a
:
b
,
10
:
20
])
r8
=
f8
(
vx
,
m
,
n
)
t8
=
vx
[
m
:
n
,
10
:
20
]
assert
r8
.
shape
==
t8
.
shape
assert
numpy
.
all
(
r8
.
toarray
()
==
t8
.
toarray
())
f9
=
theano
.
function
([
x
,
a
,
b
],
x
[
1
:
a
,
1
:
b
])
f9
=
theano
.
function
([
x
,
a
,
b
],
x
[
1
:
a
,
1
:
b
])
r9
=
f9
(
vx
,
p
,
q
)
t9
=
vx
[
1
:
p
,
1
:
q
]
assert
r9
.
shape
==
t9
.
shape
assert
numpy
.
all
(
r9
.
toarray
()
==
t9
.
toarray
())
def
test_GetItemScalar
():
sparse_formats
=
(
'csc'
,
'csr'
)
for
format
in
sparse_formats
:
...
...
@@ -1026,8 +1027,8 @@ def test_GetItemScalar():
m
=
50
n
=
50
vx
=
as_sparse_format
(
numpy
.
random
.
binomial
(
1
,
0.5
,
(
100
,
100
)),
format
)
.
astype
(
theano
.
config
.
floatX
)
vx
=
as_sparse_format
(
numpy
.
random
.
binomial
(
1
,
0.5
,
(
100
,
100
)),
format
)
.
astype
(
theano
.
config
.
floatX
)
f1
=
theano
.
function
([
x
,
a
,
b
],
x
[
a
,
b
])
r1
=
f1
(
vx
,
10
,
10
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论